diff mbox

[review,gdb/threads] Fix hang in stop_all_threads after killing inferior

Message ID 20200129160212.E3DF920AF7@gnutoolchain-gerrit.osci.io
State New
Headers show

Commit Message

Simon Marchi (Code Review) Jan. 29, 2020, 4:02 p.m. UTC
Tom de Vries has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/759
......................................................................


Patch Set 1:

> Patch Set 1:
> 
> This seems very similar to https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/133
> - I don't think there should be any logic specific to SIGKILL here. It seems like a
> general race condition for early termination while `stop_all_threads` is being executed.

Thanks for noticing, that's useful.

FWIW, I looked over the review comments there, and noticed the suggestion to "leave the TARGET_WAITKIND_EXITED/TARGET_WAITKIND_SIGNALLED event pending", which I tried using this additional patch:
...
...

But I didn't notice any difference in behaviour.
diff mbox

Patch

diff --git a/gdb/infrun.c b/gdb/infrun.c
index e34ddc83b45..c1035c25d7f 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -4774,7 +4774,11 @@  stop_all_threads (void)
 
          if (event.ws.kind == TARGET_WAITKIND_SIGNALLED
              && event.ws.value.sig == GDB_SIGNAL_KILL)
-           goto done;
+           {
+             thread_info *t = find_thread_ptid (event.target, event.ptid);
+             save_waitstatus (t, &event.ws);
+             goto done;
+           }
          else if (event.ws.kind == TARGET_WAITKIND_NO_RESUMED
              || event.ws.kind == TARGET_WAITKIND_THREAD_EXITED
              || event.ws.kind == TARGET_WAITKIND_EXITED