From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
To: gdb@sourceware.org
Subject: Re: gdbserver and "terminated with signal SIGTRAP"
Date: Fri, 30 Nov 2007 08:58:00 -0000 [thread overview]
Message-ID: <20071130.175814.18313162.nemoto@toshiba-tops.co.jp> (raw)
In-Reply-To: <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
next prev parent reply other threads:[~2007-11-30 8:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-29 14:53 Atsushi Nemoto
2007-11-30 8:58 ` Atsushi Nemoto [this message]
2007-11-30 14:47 ` Daniel Jacobowitz
2007-11-30 14:58 ` Atsushi Nemoto
2007-11-30 15:14 ` Daniel Jacobowitz
2007-11-30 15:36 ` Atsushi Nemoto
2007-11-30 15:51 ` Daniel Jacobowitz
2007-12-03 13:46 ` Atsushi Nemoto
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071130.175814.18313162.nemoto@toshiba-tops.co.jp \
--to=anemo@mba.ocn.ne.jp \
--cc=gdb@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox