Bug 487212 - libthread_db does not work (error TD_TLSDEFER)
Summary: libthread_db does not work (error TD_TLSDEFER)
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: glibc
Version: rawhide
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: F11Blocker, F11FinalBlocker
TreeView+ depends on / blocked
 
Reported: 2009-02-24 19:29 UTC by Jan Kratochvil
Modified: 2018-04-11 08:50 UTC (History)
6 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2009-03-03 10:10:31 UTC
Type: ---
Embargoed:


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

Description Jan Kratochvil 2009-02-24 19:29:32 UTC
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 14:27:35 UTC
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-28 02:39:37 UTC
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.