Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 156157 - sys-devel/gdb - linking against libpthread without using pthread functions gives "generic error"
Summary: sys-devel/gdb - linking against libpthread without using pthread functions gi...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: x86 Linux
: High critical (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-24 15:26 UTC by Michael Lee Yohe
Modified: 2008-02-25 03:56 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Lee Yohe 2006-11-24 15:26:08 UTC
I recently emerged in glibc-2.4-r4 (latest stable) and it now causes a problem debugging applications.  Architecture is x86.  The error specifically is:

$ gdb ./prog
GNU gdb 6.4
Copyright 2005 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: /home/me/dev/src/prog
[Thread debugging using libthread_db enabled]
Error while reading shared library symbols:
Cannot find new threads: generic error

When this occurs, I am unable to break from the debugger and it must be killed with a -9 from another terminal.  I re-emerged gdb and glibc if that would do the trick but it is still broken.
Comment 1 SpanKY gentoo-dev 2006-11-26 05:36:54 UTC
you neglected to post `emerge info`, do so now
Comment 2 Michael Lee Yohe 2006-11-26 20:49:04 UTC
Portage 2.1.1-r2 (default-linux/x86/2006.0, gcc-4.1.1, glibc-2.4-r4, 2.6.18-gentoo-r2 i686)
=================================================================
System uname: 2.6.18-gentoo-r2 i686 Intel(R) Xeon(TM) CPU 2.80GHz
Gentoo Base System version 1.12.6
Last Sync: Sun, 26 Nov 2006 11:20:01 +0000
app-admin/eselect-compiler: [Not Present]
dev-java/java-config: [Not Present]
dev-lang/python:     2.4.3-r4
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     [Not Present]
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.60
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2
sys-devel/binutils:  2.16.1-r3
sys-devel/gcc-config: 1.3.13-r4
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.17-r1
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-march=pentium4 -mtune=prescott -O2 -mmmx -msse3 -mfpmath=sse -funroll-loops -fweb -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/env.d /etc/gconf /etc/revdep-rebuild /etc/terminfo"
CXXFLAGS="-O2 -mcpu=i686 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig distlocks metadata-transfer sandbox sfperms strict"
GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo"
LANG="en_US"
MAKEOPTS="-j4"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/distfiles' --exclude='/local' --exclude='/packages'"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="x86 alsa apache2 apm arts bash-completion berkdb bitmap-fonts cli cracklib crypt cups dlloader dri eds elibc_glibc emboss encode esd foomaticdb gdbm gif gpm gstreamer gtk2 iconv imlib input_devices_evdev input_devices_keyboard input_devices_mouse isdnlog jpeg kernel_linux libg++ libwww mad mbox mikmod mmx mmxext motif mp3 mpeg mpm-worker ncurses notmp nptl nptlonly ogg opengl oss pam pcre perl png pppd python qt3 qt4 quicktime readline reflection sdl session spell spl sqlite sse sse2 ssl tcpd threads truetype truetype-fonts type1-fonts udev userland_GNU video_cards_apm video_cards_ark video_cards_ati video_cards_chips video_cards_cirrus video_cards_cyrix video_cards_dummy video_cards_fbdev video_cards_glint video_cards_i128 video_cards_i740 video_cards_i810 video_cards_imstt video_cards_mga video_cards_neomagic video_cards_nsc video_cards_nv video_cards_rendition video_cards_s3 video_cards_s3virge video_cards_savage video_cards_siliconmotion video_cards_sis video_cards_sisusb video_cards_tdfx video_cards_tga video_cards_trident video_cards_tseng video_cards_v4l video_cards_vesa video_cards_vga video_cards_via video_cards_vmware video_cards_voodoo vorbis xml xorg xv zlib"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, LDFLAGS, LINGUAS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 3 SpanKY gentoo-dev 2006-11-26 20:56:13 UTC
does gdb-6.5-r2 fail as well ?  what if you emerge gdb with USE=vanilla ?  what does `file /lib/lib*thread*` say ?
Comment 4 Michael Lee Yohe 2006-11-26 21:17:11 UTC
> what does `file /lib/lib*thread*` say ?

$ file /lib/lib*thread*
/lib/libpthread-2.4.so:   ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, not stripped
/lib/libpthread.so.0:     symbolic link to `libpthread-2.4.so'
/lib/libthread_db-1.0.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, not stripped
/lib/libthread_db.so.1:   symbolic link to `libthread_db-1.0.so'

> does gdb-6.5-r2 fail as well ?

Yes, it fails (but allows me to terminate the debugging session versus having to send the process a KILL):

> what does `file /lib/lib*thread*` say ?

$ file /lib/lib*thread*
/lib/libpthread-2.4.so:   ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, not stripped
/lib/libpthread.so.0:     symbolic link to `libpthread-2.4.so'
/lib/libthread_db-1.0.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, not stripped
/lib/libthread_db.so.1:   symbolic link to `libthread_db-1.0.so'

> does gdb-6.5-r2 fail as well ?

Yes, it fails (but allows me to terminate the debugging session versus having to send the process a KILL):

$ gdb ./prog
GNU gdb 6.5
Copyright (C) 2006 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: /home/me/dev/src/prog 
[Thread debugging using libthread_db enabled]
Error while reading shared library symbols:
Cannot find new threads: generic error
Cannot find user-level thread for LWP 9761: generic error
(gdb) quit
The program is running.  Exit anyway? (y or n) y

$

> what if you emerge gdb with USE=vanilla ?

Non-gentoo patches do not seem to do anything.  gdb still fails like above.
Comment 5 Michael Lee Yohe 2006-11-26 21:22:01 UTC
I've seem to have isolated the problem.

If you link against libpthread (-lpthread) but don't use any pthread functions (I'm assuming), it apparently triggers this bug.  I removed the LDFLAGS entry and seem to be able to debug now.  Technically, I don't need to link against libpthread, but should this cause this gdb fault now?  Considering the makefile has been as is for quite some time... I would think that some recent change to glibc has triggered this problem.
Comment 6 SpanKY gentoo-dev 2006-11-27 08:20:25 UTC
works for me ... can you post the binary you're testing ?

$ echo 'int main(){}' > test.c
$ gcc test.c -lpthread
$ gdb ./a.out 
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) r
Starting program: /home/vapier/a.out 
[Thread debugging using libthread_db enabled]
[New Thread 57138792023792 (LWP 28625)]

Program exited with code 0260.
(gdb) 
Comment 7 SpanKY gentoo-dev 2006-11-27 08:21:23 UTC
that was amd64 ... i can reproduce on my x86
Comment 8 SpanKY gentoo-dev 2008-02-25 03:56:45 UTC
glibc-2.7 and gdb-6.7.1 on x86 seems to work OK now