This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] Fix for gdb crash in "info thread" after exec().


Greetings,

Gdb (CVS Head) crashes when 'info thread' is executed after program exec()s:

$ cat execl.c
#include <unistd.h>
int
main (int argc, char* argv[])
{
  if (argc == 1)
    execl (argv[0], argv[0], "second", NULL);

  return 0;
}

$ gcc -g execl.c -pthread && ./gdb -nx -q a.out
(gdb) b main
Breakpoint 1 at 0x8048388: file execl.c, line 5.
(gdb) r
Starting program: /usr/local/build/gdb/a.out
[Thread debugging using libthread_db enabled]

Breakpoint 1, main (argc=1, argv=0xffffd744) at execl.c:5
5         if (argc == 1)
(gdb) c
Continuing.
warning: Error removing breakpoint -2
warning: Error removing breakpoint -3
[New process 5418]
Executing new program: /usr/local/build/gdb/a.out
warning: Cannot initialize thread debugging library: generic error
[Thread debugging using libthread_db enabled]

Breakpoint 1, main (argc=2, argv=0xffffd744) at execl.c:5
5         if (argc == 1)
(gdb) inf thread
../../src/gdb/linux-nat.c:2960: internal-error:
linux_nat_thread_alive: Assertion `is_lwp (ptid)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) y


The problem is that gdb maintains thread list which is not properly
re-initialized after exec().

Attached patch (originally by Doug Evans <dje@google.com>) fixes
that, and adds a test case for it.

Thanks,
-- 
Paul Pluzhnikov

ChangeLog:
2008-05-12  Paul Pluzhnikov  <ppluzhnikov@google.com>

	* gdb/linux-thread-dl.c (check_for_thread_db): reinitialize
	thread list after exec().

testsuite/ChangeLog:
2008-05-12  Paul Pluzhnikov  <ppluzhnikov@google.com>

	* gdb.threads/execl.c, gdb.threads/execl.exp: Add test for
	"info threads" after exec.

Attachment: gdb-20080512-patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]