
On Wed, Jan 21, 2015 at 8:57 AM, Vicente J. Botet Escriba
Le 21/01/15 00:50, Gaetano Mendola a écrit :
I'm using clang 3.6 with boost 1.54
$ clang-3.6 --version Ubuntu clang version 3.6.0-svn225356-1~exp1 (trunk) (based on LLVM 3.6.0) Target: x86_64-pc-linux-gnu Thread model: posix
Compiling the code here: http://pastebin.com/zh0SPz5n
$ clang++-3.6 -g main.cpp -lboost_system -lboost_thread -fsanitize=thread
I get at runtime:
================== WARNING: ThreadSanitizer: data race (pid=5592) <snip> SUMMARY: ThreadSanitizer: data race ??:0 operator delete(void*) ==================
I believe this is a false alarm indeed the two threads are working on their own shared_ptr copy and thePtr shared pointer write/read in the two threads is protected with a mutex.
I will open a ticket with clang folks if you recognize that is a false alarm, unless they are right and we have issue in shared_ptr implementation.
Thanks for raising this issue. The Boost.Thread regression tests are showing this kind of issues since the testers were installed by Marshall.
Your example seems to show that the issue is only related to boost::shared_ptr. In order we can concentrate only on Boost::SmartPtr, could you give a try replacing Boost.Thread by (std::thread/mutex/unique_lock)?
This is not specific to Boost.SmartPtr. Any library that implements atomics, including Boost.Atomic and std::atomic, will likely be present in TSan reports. The problem is that TSan does not fully support C++ memory ordering arguments. See this thread: http://boost.2283326.n4.nabble.com/atomic-ThreadSanitizer-reports-a-data-rac...