This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: gdbserver and "terminated with signal SIGTRAP"
- From: Atsushi Nemoto <anemo at mba dot ocn dot ne dot jp>
- To: gdb at sourceware dot org
- Date: Fri, 30 Nov 2007 17:58:14 +0900 (JST)
- Subject: Re: gdbserver and "terminated with signal SIGTRAP"
- References: <20071129.235502.95065374.anemo@mba.ocn.ne.jp>
On Thu, 29 Nov 2007 23:55:02 +0900 (JST), Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> I confirmed that maybe_attach_thread() in thread-db.c did not call
> linux_attach_lwp() on the second time. That was because
> find_inferior_id() returned non NULL value. It seems
> find_inferior_id() returned the first thread (which should be dead
> before the second thread creation).
Now I understand why find_inferior_id() misbehaves. The "id" is
actually pthread_t and it might be recycled.
For example, This program shows same id values!
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
void *func(void *data)
{
return data;
}
int main(int argc, char **argv)
{
pthread_t id;
int i;
for (i = 0; i < 4; i++) {
pthread_create(&id, NULL, func, NULL);
printf("%x\n", id);
pthread_join(id, NULL);
}
return 0;
}
$ ./foo
b7fdbb90
b7fdbb90
b7fdbb90
b7fdbb90
But... how can this be avoided?
---
Atsushi Nemoto