This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb/gdb-7.10-branch] gdbserver/Linux: internal error when killing a process that is already gone


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=68988aba52a4c6355b03834f70bcebbd114be2cd

commit 68988aba52a4c6355b03834f70bcebbd114be2cd
Author: Pedro Alves <palves@redhat.com>
Date:   Tue Jul 14 10:48:05 2015 +0100

    gdbserver/Linux: internal error when killing a process that is already gone
    
    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.

Diff:
---
 gdb/gdbserver/ChangeLog   | 5 +++++
 gdb/gdbserver/linux-low.c | 5 ++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 081d305..33a90e6 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -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-02  Markus Metzger  <markus.t.metzger@intel.com>
 
 	* linux-low.c: Include "rsp-low.h"
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 7bb9f7f..2dafb03 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -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,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]