Description of problem: Originally reported in Bug 486494 as broken GDB. Version-Release number of selected component (if applicable): glibc-2.9.90-7.x86_64 - broken Verified as OK on the same system: glibc-2.9-3.x86_64 How reproducible: Always. Steps to Reproduce: echo 'int main (void) { return 0; }' >threadmain.c; gcc -o threadmain threadmain.c -Wall -g -pthread; gdb -nx -ex r ./threadmain Actual results: GNU gdb (GDB) Fedora (6.8.50.20090210-1.fc11) Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-redhat-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Starting program: /root/jkratoch/redhat/threadmain [Thread debugging using libthread_db enabled] Error while reading shared library symbols: find_new_threads_callback: cannot get thread info: generic error find_new_threads_callback: cannot get thread info: generic error (gdb) q Expected results: GNU gdb (GDB) Fedora (6.8.50.20090210-1.fc11) Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-redhat-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Starting program: /root/jkratoch/redhat/threadmain [Thread debugging using libthread_db enabled] Program exited normally. Missing separate debuginfos, use: debuginfo-install glibc-2.9-3.x86_64 (gdb) q Additional info: Problem is unrelated to the GDB version/variant in use. Problem was also reproducible on an artificial libthread_db testcase: http://cvs.jankratochvil.net/viewcvs/debugger/debugger.tar.gz?tarball=1 libthread_db returns TD_TLSDEFER.
Created attachment 333164 [details] objdump output of libpthread.a Saw this too, the problem is that in glibc/nptl/init.c there's a 'static boolean nptl_initial_report_events' that's used by thread_db to detect if threads have been started already. This boolean is optimized away by gcc/ld where gdb later actively tries to find it. Solution: remove 'static' here. Cheers, Ronald.
Should be fixed in glibc-2.9.90-8.1, building now. (Fixes are upstream, Jakub's next rebase will pull them in more properly too.) But note that thread_db is really only needed nowadays for two things: user-visible thread IDs (pthread_t), and TLS. So I would hope that when thread_db fails, gdb can be robust enough to keep working happily and just not have pthread_t's to display (can display Linux TIDs instead) and can't do TLS variables.