Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 46186 - gdb nptl support broken by overzealous glibc stripping
Summary: gdb nptl support broken by overzealous glibc stripping
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: x86 Linux
: High normal
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
: 46323 48116 51117 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-03-29 19:30 UTC by Luke
Modified: 2023-12-27 04:13 UTC (History)
11 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
test.c (test.c,2.15 KB, text/x-csrc)
2004-04-07 04:15 UTC, Stefan Jones (RETIRED)
Details
glibc.spec (glibc.spec,86.67 KB, text/plain)
2004-04-07 04:17 UTC, Stefan Jones (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Luke 2004-03-29 19:30:08 UTC
gdb runs without thread support unless I do FEATURES="nostrip" emerge glibc.

I found this solution from the following forums:
http://forums.gentoo.org/viewtopic.php?t=147172
http://forums.gentoo.org/viewtopic.php?t=153520

Apparently the glibc ebuild should ensure that /lib/libthread_db-1.0.so is not stripped.

Reproducible: Always
Steps to Reproduce:
1.debug a program with gdb


Actual Results:  
thread operations like "info threads" fail; signals like SIGSEGV are not caught
by gdb

Expected Results:  
gdb should operate with full thread and signal support enabled

Portage 2.0.50-r1 (default-x86-2004.0, gcc-3.3.2, glibc-2.3.3_pre20040207-r0, 2.
6.5-rc2)
=================================================================
System uname: 2.6.5-rc2 i686 Intel(R) Pentium(R) 4 CPU 3.20GHz
Gentoo Base System version 1.4.3.13
Autoconf: sys-devel/autoconf-2.58-r1
Automake: sys-devel/automake-1.7.7
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CFLAGS="-O3 -march=pentium4 -mmmx -msse -msse2 -mfpmath=sse -fomit-frame-pointer
 -pipe"
CHOST="i686-pc-linux-gnu"
COMPILER="gcc3"
CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3/s
hare/config /usr/lib/mozilla/defaults/pref /usr/share/config /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-O3 -march=pentium4 -mmmx -msse -msse2 -mfpmath=sse -fomit-frame-point
er -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs ccache sandbox"
GENTOO_MIRRORS="http://mirror.pacific.net.au/gentoo/"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY=""
SYNC="rsync://mirror.pacific.net.au/gentoo-portage"
USE="X Xaw3d aalib acpi avi berkdb crypt cups encode fastcgi firebird foomaticdb
 gdbm gif gpm gtk2 imap imlib java jpeg ldap libg++ libwww mad mikmod mmx mozcal
endar mozilla mpeg ncurses nls nogjc nptl oggvorbis oss pam pdflib perl png pyth
on qt quicktime readline samba sasl sdl slang spell sse sse2 ssl tcpd tiff tls t
ruetype x86 xml2 xmms zlib"
Comment 1 Stefan Jones (RETIRED) gentoo-dev 2004-04-07 04:13:51 UTC
I have done some tests compiling:

As per Bug 45756 I compiled glibc with CFLAGS="-march=i686 -O3 -pipe" and installed it into a chroot.

I then used a test program (attached). It just creates threads.

When run though gdb on the unstripped system I get:
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 "i686-pc-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".
 
(gdb) r
Starting program: /test
[Thread debugging using libthread_db enabled]
[New Thread 1073843040 (LWP 24186)]
[New Thread 1083554736 (LWP 24189)]
created thread 0
[New Thread 1091951536 (LWP 24190)]
created thread 1
[New Thread 1100344240 (LWP 24191)]
created thread 2
[New Thread 1108736944 (LWP 24192)]
created thread 3
[New Thread 1117129648 (LWP 24193)]
created thread 4
[New Thread 1125522352 (LWP 24194)]
created thread 5
[New Thread 1133915056 (LWP 24195)]
created thread 6
[New Thread 1142307760 (LWP 24196)]
created thread 7
[New Thread 1150700464 (LWP 24197)]
created thread 8
[New Thread 1159093168 (LWP 24198)]
created thread 9
[New Thread 1167485872 (LWP 24199)]
created thread 10
[New Thread 1175878576 (LWP 24200)]
created thread 11
[New Thread 1184271280 (LWP 24201)]
created thread 12
[New Thread 1192663984 (LWP 24202)]
created thread 13
[New Thread 1201056688 (LWP 24203)]
created thread 14
[New Thread 1209449392 (LWP 24204)]
created thread 15
[New Thread 1217842096 (LWP 24205)]
created thread 16
[New Thread 1226234800 (LWP 24206)]
created thread 17
[New Thread 1234627504 (LWP 24207)]
created thread 18
[New Thread 1243020208 (LWP 24208)]
created thread 19
 
Program exited normally.

Note the "New Thread XXXX" lines.

Doing:
saj lib # strip --strip-unneeded libc-2.3.3.so
saj lib # strip --strip-unneeded libm-2.3.3.so
does not effect the output.

But when I do:
saj lib # strip --strip-unneeded libpthread-0.60.so
I now get the bad gdb output:
GNU gdb 6.1
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 "i686-pc-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".
 
(gdb) r
Starting program: /test
created thread 0
created thread 1
created thread 2
created thread 3
created thread 4
created thread 5
created thread 6
created thread 7
created thread 8
created thread 9
created thread 10
created thread 11
created thread 12
created thread 13
created thread 14
created thread 15
created thread 16
created thread 17
created thread 18
created thread 19
 
Program exited normally.

Note no "New Thread" lines.

Thus the glibc libraries should not be stripped.

I will also attach the glibc Fedora RPM spec for referance on what files can be stripped.
Comment 2 Stefan Jones (RETIRED) gentoo-dev 2004-04-07 04:15:22 UTC
Created attachment 28825 [details]
test.c

A small program which creates threads.
gcc -o test test.c -lpthread to compile
Comment 3 Stefan Jones (RETIRED) gentoo-dev 2004-04-07 04:17:01 UTC
Created attachment 28826 [details]
glibc.spec

Glibc spec file from Fedora.
Note which files are stripped
Comment 4 Olivier Crete (RETIRED) gentoo-dev 2004-04-12 09:36:45 UTC
Maybe using the separate debug information options of gdb6 might help us here... look at #45150 for portage support.. Remember that fedora ship -debuginfo files for everything now.. Maybe hardcoding it to use eu-strip in the glibc ebuild might be a way to fix this..
Comment 5 Loz Hygate 2004-07-06 11:50:03 UTC
Could the gdb parts of bug 55146 be related? I am using nostrip, I can see back traces, but there are obvious problems.
Comment 6 SpanKY gentoo-dev 2004-07-31 00:16:09 UTC
*** Bug 46323 has been marked as a duplicate of this bug. ***
Comment 7 SpanKY gentoo-dev 2004-07-31 00:16:13 UTC
*** Bug 48116 has been marked as a duplicate of this bug. ***
Comment 8 SpanKY gentoo-dev 2004-07-31 00:17:01 UTC
unless someone points out something obvious in the next ~24 hours i'm going to update the glibc ebuilds to not strip libthread_db
Comment 9 Stefan Jones (RETIRED) gentoo-dev 2004-08-01 09:48:22 UTC
It may help if you read my data first, you need to stop stipping of not just libpthread_db but libpthread (the normal one) as well.
Run the test after you modified the ebuild as per comment #1
( or I can do it, email me the ebuild or something and I will test )
Comment 10 SpanKY gentoo-dev 2004-08-02 17:01:07 UTC
fixed in glibc-2.2.5-r9, glibc-2.3.2-r10, and glibc-2.3.4.20040619
Comment 11 SpanKY gentoo-dev 2004-08-19 19:26:21 UTC
*** Bug 51117 has been marked as a duplicate of this bug. ***
Comment 12 Jaroslav Sladek 2004-10-09 03:41:32 UTC
If I understand things correctly, it still hasn't been correct in 2.3.3.20040420-r2, which was just recently marked stable on x86. So update world just nearly replaced glibc I custom compiled with FEATURES=nostrip with glibc containing stripped libpthreads again, if I hadn't stopped it in last minute. 

As it seems, the only ebuild where this isn't fixed now is this one, which is the latest stable one on x86. I really wonder why, since it's arguably what most people will use. So for now I still need to emerge glibc with FEATURES=nostrip, since downgrading glibc is not really an option, 2.3.4 is marked ~x86 and I do need thread debugging.

Comment 13 Stefan Jones (RETIRED) gentoo-dev 2004-10-12 12:15:10 UTC
united ~ # emerge glibc -p

These are the packages that I would merge, in order:

Calculating dependencies ...done!
[ebuild   R   ] sys-libs/glibc-2.3.4.20041006


united ~ # file /lib/tls/libpthread-2.3.4.so
/lib/tls/libpthread-2.3.4.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), stripped

Some small bug in the glibc install method, if you want to debug nptl ....

united ~ # file /lib/libpthread-0.10.so
/lib/libpthread-0.10.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), not stripped

if fine though
Comment 14 Stefan Jones (RETIRED) gentoo-dev 2004-10-12 13:13:17 UTC
Ok,

Here is what is wrong with glibc-2.3.4.20041006:

From emerge log:

mkdir: invalid option -- o
Try `mkdir --help' for more information.
mv: when moving multiple files, last argument must be a directory
Try `mv --help' for more information.
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
prepallstrip:
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
strip:
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
strip:
   lib/tls/libpthread-2.3.4.so
   lib/tls/librt-2.3.4.so
   lib/tls/libm-2.3.4.so
   lib/tls/libthread_db-1.0.so

And:

united glibc-2.3.4.20041006 # ls /var/tmp/portage/glibc-2.3.4.20041006/temp/thread-backup
libpthread-0.10.so  libpthread.so.0  libthread_db-1.0.so  libthread_db.so.1

In the ebuild ::

mkdir -o ${T}/thread-backup/tls

??? -o BUG!!!!!
Comment 15 Stefan Jones (RETIRED) gentoo-dev 2004-10-14 08:53:30 UTC
Fixed a few days ago ...
Comment 16 Jaroslav Sladek 2004-10-15 00:59:04 UTC
2.3.3.20040420-r2 still isn't fixed (as per my previous comment), but since 2.3.4.20040808-r1 was recenetly marked stable for x86, it's no longer really an issue on this architecture. 
Comment 17 Andre Kloth 2005-10-03 13:31:06 UTC
Today I tried to debug a threaded program, but failed because gdb uses the
libthread_db library "/lib/tls/libthread_db.so.1" -- which is stipped :-(

As a work-a-round i moved /lib/tls away.

The USE flags of my glibc are only nptl and nls. 

Is it correct that /lib/tls/libpthread-2.3.5.so is stripped but
/lib/libpthread-0.10.so is not? I am really confused ...
Comment 18 Stefan Jones (RETIRED) gentoo-dev 2005-10-03 13:51:07 UTC
See bug #101374

It was fixed but then broke for a few days. (a long time ago)
Try remerging glibc I guess.

( you could check the ebuild in /var/db/pkg/*/glibc* to see if it has the bug I
suppose )
Comment 19 Maxim Polunin 2007-08-15 23:44:59 UTC
the same problem with glibc 2.6/2.6.1
libpthread is stripped, libthread_db.so is not.
adding nostrip to FEATURES helps
Comment 20 Nathan Caldwell 2007-10-29 23:38:36 UTC
(In reply to comment #19)
> the same problem with glibc 2.6/2.6.1
> libpthread is stripped, libthread_db.so is not.
> adding nostrip to FEATURES helps
> 

I posted a patch for this over at bug 196031. Maybe someone that gets CC'd here has the power to fix it.
Comment 21 Larry the Git Cow gentoo-dev 2019-09-25 08:04:53 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e14229b10b513a164f8379ff14cc8c644c071f27

commit e14229b10b513a164f8379ff14cc8c644c071f27
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2019-09-25 07:27:26 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2019-09-25 08:04:44 +0000

    sys-libs/glibc: drop prepallstrip, bug #587296
    
    Stop using internal portage's 'prepallstrip' helper.
    This effectively reverts https://bugs.gentoo.org/46186.
    Modern gdb can inspect threads without debugging symbols
    in libpthread/libthread_db.
    
    Reported-by: Michał Górny
    Closes: https://bugs.gentoo.org/587296
    Bug: https://bugs.gentoo.org/46186
    Package-Manager: Portage-2.3.76, Repoman-2.3.17
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 sys-libs/glibc/glibc-2.19-r2.ebuild  | 19 -------------------
 sys-libs/glibc/glibc-2.24-r4.ebuild  |  3 +--
 sys-libs/glibc/glibc-2.25-r11.ebuild |  3 +--
 sys-libs/glibc/glibc-2.26-r7.ebuild  |  4 +---
 sys-libs/glibc/glibc-2.27-r6.ebuild  | 19 -------------------
 sys-libs/glibc/glibc-2.28-r6.ebuild  | 19 -------------------
 sys-libs/glibc/glibc-2.29-r2.ebuild  | 19 -------------------
 sys-libs/glibc/glibc-2.29-r4.ebuild  | 19 -------------------
 sys-libs/glibc/glibc-2.29-r5.ebuild  | 19 -------------------
 sys-libs/glibc/glibc-2.30-r1.ebuild  | 20 --------------------
 sys-libs/glibc/glibc-2.30.ebuild     | 20 --------------------
 sys-libs/glibc/glibc-9999.ebuild     |  5 -----
 12 files changed, 3 insertions(+), 166 deletions(-)

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cdb645361e3e3f20bb6f1250ada03e802285ffc3

commit cdb645361e3e3f20bb6f1250ada03e802285ffc3
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2019-09-25 07:19:16 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2019-09-25 08:04:44 +0000

    toolchain-glibc.eclass: drop prepallstrip, bug #587296
    
    This effectively reverts https://bugs.gentoo.org/46186.
    Modern gdb can inspect threads without debugging symbols
    in libpthread/libthread_db.
    
    Reported-by: Michał Górny
    Bug: https://bugs.gentoo.org/587296
    Bug: https://bugs.gentoo.org/46186
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 eclass/toolchain-glibc.eclass | 18 ------------------
 1 file changed, 18 deletions(-)
Comment 22 Larry the Git Cow gentoo-dev 2019-10-17 23:22:30 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f3872a506edc7da0d987bcf0a90d4709945328a7

commit f3872a506edc7da0d987bcf0a90d4709945328a7
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2019-10-17 23:19:20 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2019-10-17 23:22:21 +0000

    sys-libs/glibc: restore strip quirk for 'libpthread.so.0'
    
    This change effectively reverts commit e14229b10b513a
    ("sys-libs/glibc: drop prepallstrip, bug #587296")
    
    gdb still relies on libpthread being unstripped.
    See https://bugs.gentoo.org/697910 for details and reproducer.
    
    Also see ebuild note that explains indirect mechanics
    of how glibc relies on gdb's ability to traverse local symbols.
    
    In EAPI=7 ebuilds (glibc-9999) we do selective stripping.
    
    Reported-by: Minux
    Closes: https://bugs.gentoo.org/697910
    Bug: https://bugs.gentoo.org/587296
    Bug: https://bugs.gentoo.org/46186
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
    Package-Manager: Portage-2.3.76, Repoman-2.3.17
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 sys-libs/glibc/glibc-2.19-r2.ebuild  | 25 ++++++++++++++++++++++---
 sys-libs/glibc/glibc-2.24-r4.ebuild  | 25 ++++++++++++++++++++++---
 sys-libs/glibc/glibc-2.25-r11.ebuild | 25 ++++++++++++++++++++++---
 sys-libs/glibc/glibc-2.26-r7.ebuild  | 25 ++++++++++++++++++++++---
 sys-libs/glibc/glibc-2.27-r6.ebuild  | 25 ++++++++++++++++++++++---
 sys-libs/glibc/glibc-2.28-r6.ebuild  | 25 ++++++++++++++++++++++---
 sys-libs/glibc/glibc-2.29-r2.ebuild  | 25 ++++++++++++++++++++++---
 sys-libs/glibc/glibc-2.29-r4.ebuild  | 25 ++++++++++++++++++++++---
 sys-libs/glibc/glibc-2.29-r5.ebuild  | 25 ++++++++++++++++++++++---
 sys-libs/glibc/glibc-2.30-r1.ebuild  | 25 ++++++++++++++++++++++---
 sys-libs/glibc/glibc-2.30.ebuild     | 25 ++++++++++++++++++++++---
 sys-libs/glibc/glibc-9999.ebuild     | 31 ++++++++++++++++++++++++++++---
 12 files changed, 270 insertions(+), 36 deletions(-)