TSan undefined references

1,646 views
Skip to first unread message

Neil Castelino

unread,
Nov 4, 2014, 8:53:13 PM11/4/14
to thread-s...@googlegroups.com
Hello, I do not know if this is the correct way to ask about my problem, but here goes:

I tried to compile the programs on this webpage (https://code.google.com/p/thread-sanitizer/wiki/CppManual) using gcc but get the following errors:

neil@neil-VirtualBox:~/Documents/threadSanitizer$ gcc main.c -fsanitize=thread -fPIE -pie -g
/tmp/ccLX56jx.o: In function `Thread1':
/home/neil/Documents/threadSanitizer/main.c:6: undefined reference to `__tsan_func_entry'
/home/neil/Documents/threadSanitizer/main.c:7: undefined reference to `__tsan_read4'
/home/neil/Documents/threadSanitizer/main.c:7: undefined reference to `__tsan_write4'
/home/neil/Documents/threadSanitizer/main.c:8: undefined reference to `__tsan_func_exit'
/tmp/ccLX56jx.o: In function `Thread2':
/home/neil/Documents/threadSanitizer/main.c:11: undefined reference to `__tsan_func_entry'
/home/neil/Documents/threadSanitizer/main.c:12: undefined reference to `__tsan_read4'
/home/neil/Documents/threadSanitizer/main.c:12: undefined reference to `__tsan_write4'
/home/neil/Documents/threadSanitizer/main.c:13: undefined reference to `__tsan_func_exit'
/tmp/ccLX56jx.o: In function `main':
/home/neil/Documents/threadSanitizer/main.c:16: undefined reference to `__tsan_func_entry'
/home/neil/Documents/threadSanitizer/main.c:18: undefined reference to `pthread_create'
/home/neil/Documents/threadSanitizer/main.c:19: undefined reference to `pthread_create'
/home/neil/Documents/threadSanitizer/main.c:20: undefined reference to `__tsan_read8'
/home/neil/Documents/threadSanitizer/main.c:20: undefined reference to `pthread_join'
/home/neil/Documents/threadSanitizer/main.c:21: undefined reference to `__tsan_read8'
/home/neil/Documents/threadSanitizer/main.c:21: undefined reference to `pthread_join'
/home/neil/Documents/threadSanitizer/main.c:22: undefined reference to `__tsan_func_exit'
/tmp/ccLX56jx.o: In function `_GLOBAL__sub_I_00099_0_Thread1':
/home/neil/Documents/threadSanitizer/main.c:22: undefined reference to `__tsan_init'
collect2: error: ld returned 1 exit status

I am running on ubuntu 14.04 and gcc 4.8.2 and I have installed libtsan0 and libtsan0-dbg using apt-get.
Could I possibly get help on this one?

- Neil

Konstantin Serebryany

unread,
Nov 4, 2014, 9:03:21 PM11/4/14
to thread-s...@googlegroups.com
Most of us on this list don't have experience running gcc's tsan with the ubunut's gcc. 
You may want to ask on some ubuntu forums. 

Meanwhile, if you don't mind statically linking tsan run-time (which is the default mode in clang's tsan, but not in gcc's),
add -static-libtsan to the command line. I've just verified that I can see the same problem as you do and that -static-libtsan fixes it. 

Also, please note that gcc 4.8.2 is *OLD*. 
If anything does not work in tsan with that version we will have only one recommendation for you: get the fresh clang or gcc from trunk. 

hth, 

--kcc 


--
You received this message because you are subscribed to the Google Groups "thread-sanitizer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to thread-sanitiz...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alexander Potapenko

unread,
Nov 5, 2014, 4:17:01 AM11/5/14
to thread-s...@googlegroups.com
Can you please add -v to your command line and post the output?
The problem isn't reproducible for me with gcc 4.8.2 on Ubuntu 12.04

$ gcc t.c -fsanitize=thread -fPIE -pie -g -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/gcc-4.8.2/libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --prefix=/usr/local/gcc-4.8.2
Thread model: posix
gcc version 4.8.2 (GCC)
COLLECT_GCC_OPTIONS='-fsanitize=thread' '-fPIE' '-pie' '-g' '-v'
'-mtune=generic' '-march=x86-64'
/usr/local/gcc-4.8.2/libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/cc1
-quiet -v -imultilib . -imultiarch x86_64-linux-gnu t.c -quiet
-dumpbase t.c -mtune=generic -march=x86-64 -auxbase t -g -version
-fsanitize=thread -fPIE -o /tmp/cckWmfMz.s
GNU C (GCC) version 4.8.2 (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.8.2, GMP version 5.0.2, MPFR version
3.1.0-p3, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/include
/usr/local/include
/usr/local/gcc-4.8.2/include
/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
GNU C (GCC) version 4.8.2 (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.8.2, GMP version 5.0.2, MPFR version
3.1.0-p3, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 5d3969464a8f2d750501fb893088db76
COLLECT_GCC_OPTIONS='-fsanitize=thread' '-fPIE' '-pie' '-g' '-v'
'-mtune=generic' '-march=x86-64'
as -v --64 -o /tmp/ccy8FXma.o /tmp/cckWmfMz.s
GNU assembler version 2.22 (x86_64-linux-gnu) using BFD version (GNU
Binutils for Ubuntu) 2.22
COMPILER_PATH=/usr/local/gcc-4.8.2/libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/:/usr/local/gcc-4.8.2/libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/:/usr/local/gcc-4.8.2/libexec/gcc/x86_64-unknown-linux-gnu/:/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/:/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/
LIBRARY_PATH=/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/:/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../lib64/:/lib/x86_64-linux-gnu/:/lib/../lib64/:/usr/lib/x86_64-linux-gnu/:/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-fsanitize=thread' '-fPIE' '-pie' '-g' '-v'
'-mtune=generic' '-march=x86-64'
/usr/local/gcc-4.8.2/libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/collect2
--eh-frame-hdr -m elf_x86_64 -dynamic-linker
/lib64/ld-linux-x86-64.so.2 -pie /usr/lib/x86_64-linux-gnu/Scrt1.o
/usr/lib/x86_64-linux-gnu/crti.o
/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/crtbeginS.o
-L/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2
-L/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../lib64
-L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu
-L/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../..
-ltsan /tmp/ccy8FXma.o -lgcc --as-needed -lgcc_s --no-as-needed -lc
-lgcc --as-needed -lgcc_s --no-as-needed
/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/crtendS.o
/usr/lib/x86_64-linux-gnu/crtn.o
> --
> You received this message because you are subscribed to the Google Groups
> "thread-sanitizer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to thread-sanitiz...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Alexander Potapenko
Software Engineer
Google Moscow
Reply all
Reply to author
Forward
0 new messages