From patchwork Wed Aug 31 17:14:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoine Tremblay X-Patchwork-Id: 15133 Received: (qmail 117262 invoked by alias); 31 Aug 2016 17:14:21 -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 117253 invoked by uid 89); 31 Aug 2016 17:14:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:status_, fairness, pads, premature X-HELO: usplmg20.ericsson.net Received: from usplmg20.ericsson.net (HELO usplmg20.ericsson.net) (198.24.6.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 31 Aug 2016 17:14:19 +0000 Received: from EUSAAHC008.ericsson.se (Unknown_Domain [147.117.188.96]) by (Symantec Mail Security) with SMTP id 17.5A.02488.9D117C75; Wed, 31 Aug 2016 19:20:25 +0200 (CEST) Received: from elxa4wqvvz1.dyn.mo.ca.am.ericsson.se (147.117.188.8) by smtps-am.internal.ericsson.com (147.117.188.96) with Microsoft SMTP Server (TLS) id 14.3.301.0; Wed, 31 Aug 2016 13:14:11 -0400 From: Antoine Tremblay To: CC: Antoine Tremblay Subject: [PATCH 1/2] Fix lwp_suspend/unsuspend imbalance in linux_wait_1 Date: Wed, 31 Aug 2016 13:14:05 -0400 Message-ID: <20160831171406.24057-1-antoine.tremblay@ericsson.com> MIME-Version: 1.0 X-IsSubscribed: yes This patch fixes imbalanced lwp_suspend/unsuspend calls caused by the premature choosing of another event for fairness. select_event_lwp would switch the event before a call to unsuspend_all_lwps, thus it would be called with the wrong event. This caused an assertion failure: unsuspend LWP xx, suspended=-1 when testing gdb.threads/non-stop-fair-events.exp with ARM range stepping in GDBServer. This patch moves the switch of event after the unsuspend/unstop calls. No regressions, tested on ubuntu 14.04 ARMv7 and x86. With gdbserver-native. gdb/gdbserver/ChangeLog: * linux-low.c (linux_wait_1): Move event switch after unsuspend_lwps. --- gdb/gdbserver/linux-low.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 45061ac..cdff436 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -3771,24 +3771,6 @@ linux_wait_1 (ptid_t ptid, if (!non_stop) stop_all_lwps (0, NULL); - /* If we're not waiting for a specific LWP, choose an event LWP - from among those that have had events. Giving equal priority - to all LWPs that have had events helps prevent - starvation. */ - if (ptid_equal (ptid, minus_one_ptid)) - { - event_child->status_pending_p = 1; - event_child->status_pending = w; - - select_event_lwp (&event_child); - - /* current_thread and event_child must stay in sync. */ - current_thread = get_lwp_thread (event_child); - - event_child->status_pending_p = 0; - w = event_child->status_pending; - } - if (step_over_finished) { if (!non_stop) @@ -3813,6 +3795,25 @@ linux_wait_1 (ptid_t ptid, } } + /* If we're not waiting for a specific LWP, choose an event LWP + from among those that have had events. Giving equal priority + to all LWPs that have had events helps prevent + starvation. */ + if (ptid_equal (ptid, minus_one_ptid)) + { + event_child->status_pending_p = 1; + event_child->status_pending = w; + + select_event_lwp (&event_child); + + /* current_thread and event_child must stay in sync. */ + current_thread = get_lwp_thread (event_child); + + event_child->status_pending_p = 0; + w = event_child->status_pending; + } + + /* Stabilize threads (move out of jump pads). */ if (!non_stop) stabilize_threads ();