From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: gdb-patches@sourceware.org
Subject: [gdbserver] Problems trying to resume dead threads
Date: Sat, 19 Jul 2008 17:17:00 -0000 [thread overview]
Message-ID: <200807191716.m6JHGmsA013958@d12av02.megacenter.de.ibm.com> (raw)
Hello,
gdbserver on Linux seems to have difficulties handling
the case where a thread dies while it is stopped. This can
happen during the loop over all threads in linux_resume:
1. Thread A is resumed and starts running
2. Thread A causes Thread B to be killed (e.g. by simply
calling exit ())
3. gdbserver tries and fails to resume Thread B
The appended test case shows an extreme example of this:
If you run it under gdb/gdbserver, interrupt with Ctrl-C,
and then issue "set terminate = 1" before continuing,
you'll notice the failure:
(gdb) target remote :1234
Remote debugging using :1234
[Switching to Thread 14663]
0x00002af301f82b60 in _start () from /lib64/ld-linux-x86-64.so.2
(gdb) c
Continuing.
Program received signal SIGINT, Interrupt.
0x00002af30247c491 in clone () from /lib64/libc.so.6
(gdb) set terminate = 1
(gdb) c
Continuing.
warning: Remote failure reply: E01
Program received signal 0, Signal 0.
Cannot remove breakpoints because program is no longer writable.
It might be running in another process.
Further execution is probably impossible.
0x0000000000000000 in ?? ()
uweigand@upg1:~/fsf/gdb-head-build/gdb> ./gdbserver/gdbserver :1234 ./test
Process ./test created; pid = 14246
Listening on port 1234
Remote debugging from host 127.0.0.1
Warning: ptrace(regsets_store_inferior_registers): No such process
Warning: ptrace(regsets_store_inferior_registers): No such process
ptrace: No such process.
input_interrupt, count = 1 c = 36 ('$')
ptrace(regsets_fetch_inferior_registers) PID=14246: No such process
ptrace(regsets_fetch_inferior_registers) PID=14246: No such process
Killing inferior
Interestingly enough, running the same test case under the
GDB native target works most of time (although I did get it
to fail at least once) -- even though on inspection it appeared
the loop over threads in linux_nat_resume should have the same
problem ...
Any suggestions how to fix this?
Bye,
Ulrich
#include <pthread.h>
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
volatile int terminate = 0;
void *
thread_function (void *arg)
{
int x = * (int *) arg;
while (!terminate)
;
exit (x);
return NULL;
}
int
main (int argc, char **argv)
{
pthread_attr_t attr;
pthread_t threads[256];
int args[256];
int i, j;
pthread_attr_init (&attr);
pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN);
for (j = 0; j < 256; ++j)
{
args[j] = j;
pthread_create (&threads[j], &attr, thread_function, &args[j]);
}
pthread_attr_destroy (&attr);
return 0;
}
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
next reply other threads:[~2008-07-19 17:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-19 17:17 Ulrich Weigand [this message]
2008-08-04 13:40 ` Daniel Jacobowitz
2008-08-04 18:25 ` Ulrich Weigand
2008-08-04 18:30 ` Daniel Jacobowitz
2008-08-04 19:46 ` Ulrich Weigand
2008-08-04 19:55 ` Daniel Jacobowitz
2008-08-05 21:06 ` Ulrich Weigand
2008-08-05 21:59 ` Daniel Jacobowitz
2008-08-05 22:15 ` Ulrich Weigand
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=200807191716.m6JHGmsA013958@d12av02.megacenter.de.ibm.com \
--to=uweigand@de.ibm.com \
--cc=gdb-patches@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