Using thread sanitizer

Daniel B Mosesson
Tue Mar 5 23:30:00 GMT 2013

I am attempting to use -fsanitize=thread but am getting an error one
of a two ways:

Way 1: g++ dummy.cpp -g -fsanitize=thread -pthread -shared -fPIC

This compiles just fine, and claims it links fine, but in reality, it
just sits at 0 and then segfaults at start (options determined by
following error messages)

Way 2: g++ dummy.cpp -g -fsanitize=thread -pthread -pie -fPIC
undefined reference to `__asan_init_v1'
collect2: error: ld returned 1 exit status

The program compiles just fine with g++ dummpy.cpp

Is this problem related to the fact that gcc seems to think that it is
running on "unknown linux" as opposed to "linux-gnu"? If so, how can I
fix that issue (setting --target=x86_64-linux-gnu configurers just
fine but fails to build, even after make distclean)?

uname returns:
daniel@daniel-Virtual-Machine:~$ uname -a
Linux daniel-Virtual-Machine 3.2.0-38-generic #61-Ubuntu SMP Tue Feb
19 12:18:21 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

gcc --v:
daniel@daniel-Virtual-Machine:~$ gcc -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../SomeLocalDir/configure --enable-languages=c,c++
Thread model: posix
gcc version 4.8.0 20130305 (experimental) (GCC)

More information about the Gcc-help mailing list