[cfe-dev] TSAN shows data race in ~std::shared_ptr

Ben Pope benpope81 at gmail.com
Tue Feb 18 02:18:21 PST 2014


On 18/02/14 17:39, Kostya Serebryany wrote:
>
>     Fair enough.  I'm using cmake to build, so I added the flag with
>     -DLIBCXX_CXX_FEATURE_FLAGS=-__fsanitize=thread
>
> I afraid this is not going to work. tsan-instrumented libc++.so can be
> used only with tsan-instrumented binaries.
> With non-instrumented binaries you will be getting link time errors
> (just like you did).

Looks like they were due to my clang being linked against my newly 
installed, instrumented libc++.  I've renamed that one to libc++tsan.so 
and reinstated the uninstrumented libc++.so.

> BTW, I filed a bug for better build/test system support:
> https://code.google.com/p/thread-sanitizer/issues/detail?id=48

Yeah, I think this is going to be useful.

Not sure why I can't link against my new libc++-tsan though:

$ clang++-3.5 -fsanitize=thread -std=c++11 -stdlib=libc++ 
shared_ptr_thread_safety.cpp -nodefaultlibs -lc++-tsan -lc++abi -lm -lc 
-lgcc_s -lgcc -o shared_ptr_thread_safety

$ ldd shared_ptr_thread_safety
	linux-vdso.so.1 =>  (0x00007fff2a3fe000)
	libc++.so.1 => /usr/lib/libc++.so.1 (0x00007f761245e000)
	libc++abi.so.1 => /usr/lib/libc++abi.so.1 (0x00007f761220f000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f7611f0a000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7611b42000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f761192c000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 
(0x00007f761170e000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f7611506000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f7611302000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f7613847000)

Ben




More information about the cfe-dev mailing list