Bug 487212 - libthread_db does not work (error TD_TLSDEFER)
libthread_db does not work (error TD_TLSDEFER)
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: glibc (Show other bugs)
rawhide
x86_64 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
:
Depends On:
Blocks: F11Blocker/F11FinalBlocker
  Show dependency treegraph
 
Reported: 2009-02-24 14:29 EST by Jan Kratochvil
Modified: 2009-03-03 05:10 EST (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-03-03 05:10:31 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
objdump output of libpthread.a (233 bytes, text/plain)
2009-02-25 09:27 EST, Ronald Veldema
no flags Details

  None (edit)
Description Jan Kratochvil 2009-02-24 14:29:32 EST
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.
Comment 1 Ronald Veldema 2009-02-25 09:27:35 EST
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.
Comment 2 Roland McGrath 2009-02-27 21:39:37 EST
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.

Note You need to log in before you can comment on or make changes to this bug.