From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id AE482385801B for ; Wed, 1 Dec 2021 10:40:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AE482385801B Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-170-3DjwJJjDMgSGNrqJH0B5IQ-1; Wed, 01 Dec 2021 05:40:30 -0500 X-MC-Unique: 3DjwJJjDMgSGNrqJH0B5IQ-1 Received: by mail-wm1-f69.google.com with SMTP id l6-20020a05600c4f0600b0033321934a39so692032wmq.9 for ; Wed, 01 Dec 2021 02:40:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z1Mzdi7uO28990G2rQwYD3zd9UbJy+NmAkYEbJHmyoU=; b=ekrLwjzlLVu/fwhYC2jWpJKLPhY0VkddCau+K7WdUXPCWnoCYP6+WY/hP2bGCVdFoZ Qe2A60PqO+lhxmUmCuQBeWeskbFu02L0kJtdX+uZK+d6+37bNxL+Sk0/+xxYCMXuJgwO nTqp9yZW9spaX4asZ+GV1dWEhCMlIEUBGMz6LYwLSbcZQIeTEvMWCqb5h4ikMu9feHMV joePq3yLnhR20Jvvaut3JDN/vVYr98tWDuAxBt5ppS7OPH3SOTU/RJoYa7Tscj8IAmmk /rVpwt6GpJ/42/eXmd8tnqtI8EIp0/Iv/lwEX8yTqNSMwpeTOuzxHu3ZDPj5zsxNMCXW RcDA== X-Gm-Message-State: AOAM530k4SgOISFxuCy4MUvg6a/0kbGT6CoDXpVaKZAH8ldRw2P/leiX +PPMLBjClkWJRTMnXpJ+wvDG2J7MuIOMZq3FlEToInaexNdd7+68tjl+9y2Pa8IJh/r8yLiyclV 4U/cKcU6PUBC6SVk6GAEpj/dawtCJF/Oi/0H8VC7VsH5h7G0c4M2RdbCXk/OfXJ3UVw5B1pA4NQ == X-Received: by 2002:adf:f44e:: with SMTP id f14mr5839754wrp.37.1638355228818; Wed, 01 Dec 2021 02:40:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwobF43qUll4o5ur5TdMeTkntu0u6jw1Q/CPc1QXr/OOe/uQdfzXXYrst9O7J86DSi5nHXoZg== X-Received: by 2002:adf:f44e:: with SMTP id f14mr5839736wrp.37.1638355228577; Wed, 01 Dec 2021 02:40:28 -0800 (PST) Received: from localhost (host86-134-238-138.range86-134.btcentralplus.com. [86.134.238.138]) by smtp.gmail.com with ESMTPSA id z5sm895440wmp.26.2021.12.01.02.40.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Dec 2021 02:40:28 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv3 2/2] gdb: add assert in remote_target::wait relating to async being off Date: Wed, 1 Dec 2021 10:40:23 +0000 Message-Id: <11fcb8c237803345a615a356b5ca240c7a137926.1638354426.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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: Wed, 01 Dec 2021 10:40:33 -0000 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; -- 2.25.4