[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

No GDB stack traces after deadlock



I want to file the following bug report, but I'm not sure if it's a gdb,
libc6 or libc6-dbg problem:

Package: libc6
Version: 2.3.6.ds1-11

If you don't install libc6-dbg, and set LD_LIBRARY_PATH=/usr/lib/debug,
then you get corrupted stack traces for deadlocked threads in GDB:

$ cat deadlock.c
#include <pthread.h>

int main(int argc, char** argv) {
   pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
   pthread_mutex_lock(&lock);
   pthread_mutex_lock(&lock);
}

$ gcc -g -O0 deadlock.c -o deadlock -lpthread
$ gdb ./deadlock
...
(gdb) run
Starting program: /home/sears/deadlock/deadlock
Failed to read a valid object file image from memory.
[Thread debugging using libthread_db enabled]
[New Thread -1209542976 (LWP 9659)]

// program hangs as expected, hit ^C

Program received signal SIGINT, Interrupt.
[Switching to Thread -1209542976 (LWP 9659)]
0xb7fd5410 in ?? ()
(gdb) where
#0  0xb7fd5410 in ?? ()
#1  0xbfee9698 in ?? ()
#2  0x00000002 in ?? ()
#3  0x00000000 in ?? ()
(gdb)

libc6-dbg fixes the problem:

$ export LD_LIBRARY_PATH=/usr/lib/debug/
$ gdb ./deadlock
...
(gdb) run
^C
Program received signal SIGINT, Interrupt.
[Switching to Thread 16384 (LWP 10826)]
0xb7f63b64 in __pthread_sigsuspend (set=0xbfa040f8) at
../linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c:54
54      ../linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c: No such
file or directory.
        in ../linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c
(gdb) where
#0  0xb7f63b64 in __pthread_sigsuspend (set=0xbfa040f8)
    at ../linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c:54
#1  0xb7f62728 in __pthread_wait_for_restart_signal (self=0x804a8c0) at
pthread.c:1224
#2  0xb7f64fe6 in __pthread_alt_lock (lock=0xbfa04204, self=0x804a8c0)
at restart.h:34
#3  0xb7f621dc in *__GI___pthread_mutex_lock (mutex=0xbfa041f4) at
mutex.c:123
#4  0x080483ff in main () at deadlock.c:6

This has been driving me nuts for months, and I can't find it documented
anywhere.  If this behavior is expected, the package description for
libc6-dbg needs to be updated:

> Contains unstripped shared libraries. This package is provided primarily to provide a backtrace with names in a debugger, this makes it somewhat easier to interpret core dumps. The libraries are installed in /usr/lib/debug and can be used by placing that directory in LD_LIBRARY_PATH. Most people will not need this package.

Otherwise, it's probably a bug in the libc6 package, or gdb.

Thanks,
Rusty



Reply to: