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

Kostya Serebryany kcc at google.com
Tue Feb 18 02:37:51 PST 2014


On Tue, Feb 18, 2014 at 2:18 AM, Ben Pope <benpope81 at gmail.com> wrote:

> 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
>

These are the command parameters I used to check your test case:
# LIBCXX_ROOT -- directory where I've built tsan-instrumented libc++
clang -g -I$LIBCXX_ROOT/include -I$LIBCXX_ROOT/test/support
$LIBCXX_ROOT/lib/libc++.so -Wl,-R$LIBCXX_ROOT/lib benpope.cc -std=c++11
-fsanitize=thread

>
> $ 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
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140218/9e12ebbf/attachment.html>


More information about the cfe-dev mailing list