From Bugzilla Helper: User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Description of problem: A multithreaded C++ program, when built for profiling, hangs at exit. It appears that the main thread is attempting to clean up thread-specific data, and is waiting for a signal that will never be sent (as the pthread "manager" thread has already finished). Test program: #include <pthread.h> #include <string> void* threadfunc(void* x) { std::string s = "foo"; return NULL; } int main() { pthread_t thr; pthread_create(&thr, NULL, &threadfunc, NULL); pthread_join(thr, NULL); return 0; } Build: > g++ -g -profile -static test.cpp -o test -lpthread_p Run: > ./test (it hangs) > gdb test 10628 GNU gdb Red Hat Linux (6.3.0.0-1.21rh) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". Attaching to program: /home/jason/t/test, process 10628 0x0804a974 in __pthread_sigsuspend () (gdb) info threads (gdb) where #0 0x0804a974 in __pthread_sigsuspend () #1 0x08049a41 in __pthread_wait_for_restart_signal () #2 0x0804b0ca in pthread_key_delete () #3 0x0805720d in __tcf_0 () #4 0x08064fa2 in exit () #5 0x08064230 in __libc_start_main () #6 0x08048121 in _start () (gdb) q The program is running. Quit anyway (and detach it)? (y or n) y Version-Release number of selected component (if applicable): gcc-4.0.1-4 How reproducible: Always Steps to Reproduce: See Description Actual Results: See Description Expected Results: Program exits and leaves behind a usable gmon.out. Additional info: Other attempts at building the example program, for reference (e.g. showing that the "-static" is necessary, though it is also the likely culprit for the hang): > g++ -g -profile test.cpp -o test -lpthread /usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS definition in /usr/lib/gcc/i386-redhat-linux/4.0.1/../../../libc_p.a(errno.op) section .bss /lib/libc.so.6: could not read symbols: Bad value collect2: ld returned 1 exit status > g++ -g -profile test.cpp -o test -lpthread_p /usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS definition in /usr/lib/gcc/i386-redhat-linux/4.0.1/../../../libc_p.a(errno.op) section .bss /lib/libc.so.6: could not read symbols: Bad value collect2: ld returned 1 exit status > g++ -g -profile -static test.cpp -o test -lpthread /usr/bin/ld: errno: TLS reference in /usr/lib/gcc/i386-redhat-linux/4.0.1/../../../libpthread.a(pthread_create.o) mismatches non-TLS reference in /usr/lib/gcc/i386-redhat-linux/4.0.1/../../../libc_p.a(sysdep.op) /usr/lib/gcc/i386-redhat-linux/4.0.1/../../../libc_p.a: could not read symbols: Bad value collect2: ld returned 1 exit status
Works just fine with NPTL libpthread_p.a, which is included in rawhide.