From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by sourceware.org (Postfix) with ESMTPS id 253403858404 for ; Thu, 16 Dec 2021 21:16:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 253403858404 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f52.google.com with SMTP id y196so300522wmc.3 for ; Thu, 16 Dec 2021 13:16:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=qQoVduQSFL77u1nGO16F+yNoi/Z7FAodfgVFNX0XmYc=; b=Uav6LVR0aNnoguXvOfFKHdJ06zLyJUKe+uSHsPyEfnXqycATWe3DBMV98aH87IMBhS 7NML1m6rvyizzn/W2YasNaUbynVsKLK4QIJ6w8KmKG8iV0G+TESbaXXbGqL4lutc5Hl1 UdGeIFXsEKR19IlKG002KF63NBFHVXvxTRHlxCvuCj3tYgkQoKiQZrPzrekdLWzggChx St9AXfB272HXruxB6IDtUrs9rHfYb+EfJ9Iw7IVKNCuLncM8b1RgG0LpKhTs9DLmwU+K kQ95jU2YZx7CKjTjgdsz9FwEGuxLYIxQFl29uf3e8tcHCBlu98LdHm8xVrmnZPYn1OOM Pyyw== X-Gm-Message-State: AOAM531VqO74vz0s7EBYFcgkwCpYn1CwcfZDBDiQzfvl78S6ijnP960f wANi5Y+V6CCz9b/o3FDbVNA8hSykw2I= X-Google-Smtp-Source: ABdhPJx+PY4FvqOLx6qwcAP/loowkZv/8S7ugCYJp/rZajDhWtCEt0PrXkI+3O5fZiVr01cfVvG0oA== X-Received: by 2002:a05:600c:4fc3:: with SMTP id o3mr6781057wmq.74.1639689362255; Thu, 16 Dec 2021 13:16:02 -0800 (PST) Received: from ?IPV6:2001:8a0:f912:1a00:fb57:3faf:e98:b979? ([2001:8a0:f912:1a00:fb57:3faf:e98:b979]) by smtp.gmail.com with ESMTPSA id e7sm7139996wrg.31.2021.12.16.13.16.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Dec 2021 13:16:01 -0800 (PST) Message-ID: Date: Thu, 16 Dec 2021 21:16:00 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCHv3 2/2] gdb: add assert in remote_target::wait relating to async being off Content-Language: en-US To: Andrew Burgess , gdb-patches@sourceware.org References: <11fcb8c237803345a615a356b5ca240c7a137926.1638354426.git.aburgess@redhat.com> From: Pedro Alves In-Reply-To: <11fcb8c237803345a615a356b5ca240c7a137926.1638354426.git.aburgess@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, 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: Thu, 16 Dec 2021 21:16:04 -0000 On 2021-12-01 10:40, 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 b3890d71c59..9b814d54313 100644 > --- a/gdb/remote.c > +++ b/gdb/remote.c > @@ -8295,9 +8295,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.