From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225 Description of problem: The following are the execution log. % uname -r 2.4.20-18.9smp % rpm -qa | grep glibc glibc-2.3.2-27.9 glibc-devel-2.3.2-27.9 glibc-kernheaders-2.4-8.10 glibc-common-2.3.2-27.9 % cat sample.c #include <errno.h> #include <pthread.h> #include <stdio.h> #include <stdlib.h> static void * test_thread (void *arg) { return (void *) 0; } main () { for (;;) { pthread_t id; if (pthread_create (&id, 0, test_thread, 0) != 0) printf ("pthread_create error: %s\n", strerror (errno)); else pthread_join (id, 0); } } % cc -g3 -O0 -o sample sample.c -pthread % gdb sample GNU gdb Red Hat Linux (5.3post-0.20021129.18rh) Copyright 2003 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 "i386-redhat-linux-gnu"... (gdb) run Starting program: /usr/people/ikiuo/sample/Linux/pthread [New Thread 1073976480 (LWP 12764)] [New Thread 1082371376 (LWP 12774)] [Thread 1082371376 (LWP 12774) exited] Couldn't get registers: No such process. (gdb) thread Cannot get thread info for thread 1073976480: generic error (gdb) thread 1 Cannot fetch general-purpose registers for thread 1073976480: generic error (gdb) thread 2 Cannot fetch general-purpose registers for thread 1073976480: generic error (gdb) thread 3 Cannot fetch general-purpose registers for thread 1073976480: generic error (gdb) info thread Cannot find new threads: generic error Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: 1. compile and run a sample program Additional info:
Can you try a newer glibc/kernel/binutils/kernheaders combination. A newer gdb based on 5.3.90 is also available via rawhide. Let me know if that fixes it.
I had the exact same problem trying to debug Mozilla (Couldn't get registers: No such process). gdb from the current rawhide works fine.
This works in current rawhide. Could you please confirm?
I can't debug this either, although with a different error. I tried upgrading gdb from rawhide, it didn't help. One symptom is that I can not get info on threads. "info threads" never prints anything. Also, "thread X" always returns "Thread ID X not known." Finally, breaking in the thread always causes the program to crash and exit, leaving a core file on disk. ---------------------------------------------------------------- [benign:~/tmp/test] > ls sample.c [benign:~/tmp/test] > uname -r 2.4.20-20.9 [benign:~/tmp/test] > rpm -qa | grep glibc glibc-2.3.2-27.9 glibc-devel-2.3.2-27.9 glibc-kernheaders-2.4-8.10 glibc-common-2.3.2-27.9 [benign:~/tmp/test] > rpm -q gdb gdb-5.3.90-0.20030710.21 [benign:~/tmp/test] > gcc -g3 -o sample sample.c -pthread [benign:~/tmp/test] > ls sample sample.c [benign:~/tmp/test] > gdb sample GNU gdb 5.3 Copyright 2002 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"... (gdb) b main Breakpoint 1 at 0x80484a2: file sample.c, line 18. (gdb) run Starting program: /home/ben/tmp/test/sample Breakpoint 1, main () at sample.c:18 18 if (pthread_create (&id, 0, test_thread, 0) != 0) (gdb) info thr (gdb) thr 0 Thread ID 0 not known. (gdb) thr 1 Thread ID 1 not known. (gdb) n 21 pthread_join (id, 0); (gdb) info thr (gdb) b 'test_thread' Breakpoint 2 at 0x804848b: file sample.c, line 9. (gdb) c Continuing. Breakpoint 1, main () at sample.c:18 18 if (pthread_create (&id, 0, test_thread, 0) != 0) (gdb) c Continuing. Program terminated with signal SIGTRAP, Trace/breakpoint trap. The program no longer exists. (gdb) bt No stack. (gdb) [benign:~/tmp/test] > ls -lh total 116K -rw------- 1 ben ben 8.1M Oct 5 23:08 core.2256 -rwxrwxr-x 1 ben ben 36K Oct 5 23:07 sample -rw-rw-r-- 1 ben ben 348 Oct 5 23:00 sample.c
I am experiencing the very same symptoms. When running a program with multiple threads, it shows Program received signal SIG32, Real-time event 32. 0x0843817d in __pthread_sigsuspend () evertime a new thread is created in the program. I downloaded the source and tried debugging (with print statements) and found that the wrong libthread_db. so.1 is being loaded. It finds one in the /lib/tls directory which fails to load due to a missing symbol. However, that is only a symptom since removing /lib/tls/libthread_db.so.1 so that /lib/libthread_db.so.1 loads still does not enable the multi-thread debugging capabilities. FYI uname -r 2.4.20-8
Problem is caused by kernel terminating main process when gdb attempts to continue the main process. The thread-db code is not very resilient when a thread exits unexpectedly and attempts operations which cause the error message seen to be issued. Further operations on the main thread cause further errors because the process has been terminated. The following is an excerpt of an strace of gdb running with the "set debug lin-lwp 1" command to show lin-lwp debug messages. ==================================================================== ptrace(PTRACE_CONT, 1962, 0, SIG_0) = 0 write(2, "LLR: PTRACE_CONT process 1962, 0"..., 55LLR: PTRACE_CONT process 1962, 0 (resume event thread) ) = 55 wait4(-1, 0xbfffde3c, WNOHANG|__WCLONE, NULL) = -1 ECHILD (No child processes) wait4(-1, 0xbfffde3c, WNOHANG, NULL) = 0 rt_sigsuspend([] <unfinished ...> --- SIGCHLD (Child exited) @ 0 (0) --- <... rt_sigsuspend resumed> ) = -1 EINTR (Interrupted system call) sigreturn() = ? (mask now [CHLD]) wait4(-1, 0xbfffde3c, WNOHANG|__WCLONE, NULL) = -1 ECHILD (No child processes) wait4(-1, [WIFSIGNALED(s) && WTERMSIG(s) == SIGTRAP && WCOREDUMP(s)], WNOHANG, NULL) = 1962 write(2, "LLW: waitpid 1962 received Unkno"..., 57LLW: waitpid 1962 received Unknown signal 0 (terminated) ) = 57 write(2, "LLW: Candidate event Unknown sig"..., 64LLW: Candidate event Unknown signal 0 (terminated) in LWP 1962. ) = 64 ptrace(PTRACE_GETREGS, 1962, 0, 0xbfffdb30) = -1 ESRCH (No such process)
Same for me - can't debug any multithreaded application ! glibc-2.3.2-27.9 kernel-2.4.20-8 binutils-2.13.90.0.18-9 gdb-5.3.90-0.20030710.41 gcc-3.2.2-5 Does anyone have a solution - this drives me really crazy.
It drives me nuts too. My current workaround is to recompile the program on a non-redhat machine and debug it there. For what its worth, I think this is a serious bug that should be fixed soon, or at least find a workaround. gdb+threads is completely broken..
The workaround to debug on a non-redhat machine does'nt work for me - cause some bugs only get triggered on the redhat box :( But finally .. i found a solution: it's a kernel problem. Get a recent kernel from rawhide. I tried 2.4.22-1.2115.nptl and now i can debug mt apps !!
Thanks for the bug report. However, Red Hat no longer maintains this version of the product. Please upgrade to the latest version and open a new bug if the problem persists. The Fedora Legacy project (http://fedoralegacy.org/) maintains some older releases, and if you believe this bug is interesting to them, please report the problem in the bug tracker at: http://bugzilla.fedora.us/