|
Boost Users : |
Subject: Re: [Boost-users] [atomic] ThreadSanitizer reports a data race when using the code from "reference counting" example
From: Adam Romanek (romanek.adam_at_[hidden])
Date: 2014-07-04 02:31:50
On 01.07.2014 14:15, Niall Douglas wrote:
> On 1 Jul 2014 at 13:34, Adam Romanek wrote:
>
>> See above for my private conversation with Andrey Semashev on this topic
>> (he does not follow the boost-users mailing list).
>>
>> Andrey says that the "reference counting example" from Boost.Atomic docs
>> is broken. What do you think about this?
>
> I wouldn't be surprised. Few have access to non-Intel hardware for
> testing, and all Intel CPUs always acquire loads and always release
> stores. That makes use of atomics with anything but
> memory_order_seq_cst superfluous on Intel at the CPU level.
Actually Andrey analyzed this example once again and he said he was
wrong. Let me quote him:
"After studying the standard it looks like I was wrong after all. The
paragraph 1.9/14 gives the guarantee that the compiler does not
reorder fetch_sub and the fence, so the example in the docs is
correct."
I also got confirmation from a ThreadSanitizer developer that this is a
false positive as "tsan ignores stand-alone memory fences ATM" [1].
WBR,
Adam Romanek
[1]
https://groups.google.com/d/msg/thread-sanitizer/dZ3QiQE49ns/j7rKGHg08foJ
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net