From patchwork Wed Jan 29 16:02:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 37609 Received: (qmail 47774 invoked by alias); 29 Jan 2020 16:02: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 47760 invoked by uid 89); 29 Jan 2020 16:02:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 29 Jan 2020 16:02:16 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 1710520484; Wed, 29 Jan 2020 11:02:15 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id 1153A20179; Wed, 29 Jan 2020 11:02:13 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id E3DF920AF7; Wed, 29 Jan 2020 11:02:12 -0500 (EST) X-Gerrit-PatchSet: 1 Date: Wed, 29 Jan 2020 11:02:12 -0500 From: "Tom de Vries (Code Review)" To: gdb-patches@sourceware.org Cc: Mihails Strasuns , Pedro Alves Auto-Submitted: auto-generated X-Gerrit-MessageType: comment Subject: [review] [gdb/threads] Fix hang in stop_all_threads after killing inferior X-Gerrit-Change-Id: Ibe1f29251fe2ff1c1991f041babbe18373c113b1 X-Gerrit-Change-Number: 759 X-Gerrit-ChangeURL: X-Gerrit-Commit: fe2db3d5c7f974e5387a3d2649e4c8f2d2a44bda In-Reply-To: References: X-Gerrit-Comment-Date: Wed, 29 Jan 2020 11:02:12 -0500 Reply-To: gnutoolchain-gerrit@osci.io MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Message-Id: <20200129160212.E3DF920AF7@gnutoolchain-gerrit.osci.io> 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 --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