From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id E22323858D28 for ; Tue, 23 Nov 2021 21:50:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E22323858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca Received: from [172.16.0.95] (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 6DDE21EDF0; Tue, 23 Nov 2021 16:50:04 -0500 (EST) Subject: Re: [PATCH 3/4] gdb: add assert in remote_target::wait relating to async being off To: Andrew Burgess , gdb-patches@sourceware.org References: <56b13666e9b7e54341aac22da9cfb45986f7f506.1637676250.git.aburgess@redhat.com> From: Simon Marchi Message-ID: Date: Tue, 23 Nov 2021 16:50:04 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <56b13666e9b7e54341aac22da9cfb45986f7f506.1637676250.git.aburgess@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: tl Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Nov 2021 21:50:06 -0000 On 2021-11-23 9:08 a.m., Andrew Burgess via Gdb-patches wrote: > While working on another patch I ended up in a situation where I had > async mode disabled (with 'maint set target-async off'), but the async > event token got marked anyway. > > In this situation GDB was continually calling into > remote_target::wait, however, the async token would never become > unmarked as the unmarking is guarded by target_is_async_p. > > We could just unconditionally unmark the token, but that would feel > like just ignoring a bug, so, instead, lets assert that if > !target_is_async_p, then the async token should not be marked. > > This assertion would have caught my earlier mistake. > > There should be no user visible changes with this commit. > --- > gdb/remote.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/gdb/remote.c b/gdb/remote.c > index 0c4cc6bad0b..64c4cde436b 100644 > --- a/gdb/remote.c > +++ b/gdb/remote.c > @@ -8312,9 +8312,13 @@ remote_target::wait (ptid_t ptid, struct target_waitstatus *status, > remote_state *rs = get_remote_state (); > > /* Start by clearing the flag that asks for our wait method to be called, > - we'll mark it again at the end if needed. */ > + we'll mark it again at the end if needed. If the target is not in > + async mode then the async token should not be marked. */ > if (target_is_async_p ()) > clear_async_event_handler (rs->remote_async_inferior_event_token); > + else > + gdb_assert (!async_event_handler_marked > + (rs->remote_async_inferior_event_token)); > > ptid_t event_ptid; LGTM. Simon