]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdbserver/Linux: internal error when killing a process that is already gone
authorPedro Alves <palves@redhat.com>
Tue, 14 Jul 2015 09:10:50 +0000 (10:10 +0100)
committerPedro Alves <palves@redhat.com>
Tue, 14 Jul 2015 09:10:50 +0000 (10:10 +0100)
If the process disappears (e.g., killed with "kill -9" from the shell)
while it was stopped under GDBserver's control, and the GDBserver
tries to kill it, GDBserver asserts:

 (gdb) shell kill -9 23084
 (gdb) kill
 ...
 Killing process(es): 23084
 /home/pedro/gdb/mygit/src/gdb/gdbserver/linux-low.c:972: A problem internal to GDBserver has been detected.
 kill_wait_lwp: Assertion `res > 0' failed.
 ...

gdb/gdbserver/ChangeLog:
2015-07-14  Pedro Alves  <palves@redhat.com>

* linux-low.c (kill_wait_lwp): Don't assert if waitpid fails.
Instead, ignore ECHILD, and throw an error for other errnos.

gdb/gdbserver/ChangeLog
gdb/gdbserver/linux-low.c

index e87d7b9f95e7ba2a24bcf307031eb7f8b611a34f..960b994241a507e00711a8a581e96f8dfb95ad1b 100644 (file)
@@ -1,3 +1,8 @@
+2015-07-14  Pedro Alves  <palves@redhat.com>
+
+       * linux-low.c (kill_wait_lwp): Don't assert if waitpid fails.
+       Instead, ignore ECHILD, and throw an error for other errnos.
+
 2015-07-10  Pedro Alves  <palves@redhat.com>
 
        * event-loop.c (struct callback_event) <data>: Change type to
index 7bb9f7f19fee978fdcb578794225068c28ddb2d1..2dafb033bcec62b38c930f852788895932c95748 100644 (file)
@@ -1103,7 +1103,10 @@ kill_wait_lwp (struct lwp_info *lwp)
        res = my_waitpid (lwpid, &wstat, __WCLONE);
     } while (res > 0 && WIFSTOPPED (wstat));
 
-  gdb_assert (res > 0);
+  /* Even if it was stopped, the child may have already disappeared.
+     E.g., if it was killed by SIGKILL.  */
+  if (res < 0 && errno != ECHILD)
+    perror_with_name ("kill_wait_lwp");
 }
 
 /* Callback for `find_inferior'.  Kills an lwp of a given process,