From patchwork Fri Mar 6 19:58:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 5504 Received: (qmail 53538 invoked by alias); 6 Mar 2015 19:58:18 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 53446 invoked by uid 89); 6 Mar 2015 19:58:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 06 Mar 2015 19:58:15 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t26JwDGU022520 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 6 Mar 2015 14:58:13 -0500 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t26Jw60p024787 for ; Fri, 6 Mar 2015 14:58:13 -0500 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 5/6] gdbserver/Linux: internal error when killing a process that is already gone Date: Fri, 6 Mar 2015 19:58:05 +0000 Message-Id: <1425671886-7798-6-git-send-email-palves@redhat.com> In-Reply-To: <1425671886-7798-1-git-send-email-palves@redhat.com> References: <1425671886-7798-1-git-send-email-palves@redhat.com> 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-03-06 Pedro Alves * linux-low.c (kill_wait_lwp): Don't assert if waitpid fails. Instead, ignore ECHILD, and throw an error for other errnos. --- gdb/gdbserver/linux-low.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index f9c4079..e536a51 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -970,7 +970,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,