Bug 487212

Summary: libthread_db does not work (error TD_TLSDEFER)
Product: [Fedora] Fedora Reporter: Jan Kratochvil <jan.kratochvil>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: jakub, mcepl, mcepl, roland, tromey, zyta2002
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-03-03 10:10:31 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 446452    
Attachments:
Description Flags
objdump output of libpthread.a none

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.