diff options
author | Pedro Alves <palves@redhat.com> | 2015-07-30 18:50:29 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2015-07-30 18:50:29 +0100 |
commit | 4dd63d488a76482543517c4c4cde699ee6fa33ef (patch) | |
tree | 64654e97e7cfdb2a4816a4e333fd41cdc7fecdad /gdb/testsuite/ChangeLog | |
parent | 6b940e6a063ac13372b44a03a54b6be33d22a183 (diff) | |
download | gdb-4dd63d488a76482543517c4c4cde699ee6fa33ef.zip gdb-4dd63d488a76482543517c4c4cde699ee6fa33ef.tar.gz gdb-4dd63d488a76482543517c4c4cde699ee6fa33ef.tar.bz2 |
PR threads/18600: Threads left stopped after fork+thread spawn
When a program forks and another process start threads while gdb is
handling the fork event, newly created threads are left stuck stopped
by gdb, even though gdb presents them as "running", to the user.
This can be seen with the test added by this patch. The test has the
inferior fork a certain number of times and waits for all children to
exit. Each fork child spawns a number of threads that do nothing and
joins them immediately. Normally, the program should run unimpeded
(from the point of view of the user) and exit very quickly. Without
this fix, it doesn't because of some threads left stopped by gdb, so
inferior 1 never exits.
The program triggers when a new clone thread is found while inside the
linux_stop_and_wait_all_lwps call in linux-thread-db.c:
linux_stop_and_wait_all_lwps ();
ALL_LWPS (lp)
if (ptid_get_pid (lp->ptid) == pid)
thread_from_lwp (lp->ptid);
linux_unstop_all_lwps ();
Within linux_stop_and_wait_all_lwps, we reach
linux_handle_extended_wait with the "stopping" parameter set to 1, and
because of that we don't mark the new lwp as resumed. As consequence,
the subsequent resume_stopped_resumed_lwps, called from
linux_unstop_all_lwps, never resumes the new LWP.
There's lots of cruft in linux_handle_extended_wait that no longer
makes sense. On systems with CLONE events support, we don't rely on
libthread_db for thread listing anymore, so the code that preserves
stop_requested and the handling of last_resume_kind is all dead.
So the fix is to remove all that, and simply always mark the new LWP
as resumed, so that resume_stopped_resumed_lwps re-resumes it.
gdb/ChangeLog:
2015-07-30 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
PR threads/18600
* linux-nat.c (linux_handle_extended_wait): On CLONE event, always
mark the new thread as resumed. Remove STOPPING parameter.
(wait_lwp): Adjust call to linux_handle_extended_wait.
(linux_nat_filter_event): Adjust call to
linux_handle_extended_wait.
(resume_stopped_resumed_lwps): Add debug output.
gdb/testsuite/ChangeLog:
2015-07-30 Simon Marchi <simon.marchi@ericsson.com>
Pedro Alves <palves@redhat.com>
PR threads/18600
* gdb.threads/fork-plus-threads.c: New file.
* gdb.threads/fork-plus-threads.exp: New file.
Diffstat (limited to 'gdb/testsuite/ChangeLog')
-rw-r--r-- | gdb/testsuite/ChangeLog | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 171784e..06ca987 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2015-07-30 Simon Marchi <simon.marchi@ericsson.com> + Pedro Alves <palves@redhat.com> + + PR threads/18600 + * gdb.threads/fork-plus-threads.c: New file. + * gdb.threads/fork-plus-threads.exp: New file. + 2015-07-29 Patrick Palka <patrick@parcs.ath.cx> * gdb.base/batch-preserve-term-settings.exp |