gdbserver and "terminated with signal SIGTRAP"
Atsushi Nemoto
anemo@mba.ocn.ne.jp
Fri Nov 30 08:58:00 GMT 2007
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
More information about the Gdb
mailing list