From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id hxykKblJKmoMHAEAWB0awg (envelope-from ) for ; Thu, 11 Jun 2026 01:38:01 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=bachmann.info header.i=@bachmann.info header.a=rsa-sha256 header.s=selector1 header.b=MtiUEDCV; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 9AE191E098; Thu, 11 Jun 2026 01:38:01 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 733A01E024 for ; Thu, 11 Jun 2026 01:38:00 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C260F4BA2E11 for ; Thu, 11 Jun 2026 05:37:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C260F4BA2E11 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=bachmann.info header.i=@bachmann.info header.a=rsa-sha256 header.s=selector1 header.b=MtiUEDCV Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazlp170110003.outbound.protection.outlook.com [IPv6:2a01:111:f403:c201::3]) by sourceware.org (Postfix) with ESMTPS id B2DF74BA2E09 for ; Thu, 11 Jun 2026 05:37:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B2DF74BA2E09 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=bachmann.info Authentication-Results: sourceware.org; spf=tempfail smtp.mailfrom=bachmann.info ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B2DF74BA2E09 Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:c201::3 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1781156247; cv=pass; b=X/X28duzzFX4q+8MG3X71bFbKMbiJrval/gER7/YFrwUVvTUqvqk6/ffPP9p29VwBM5XurrPcsDNHG5AJe6ZgGa9t17rMla/iMMoz9OAlQnrAExJNahG+m9mcnXhJTunh9LFlXk8IwE/pzUikYnCBVgIiZVHwYWFnbT6QZWyO+4= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1781156247; c=relaxed/simple; bh=DLLFx7gRqeeLZmCSxDMvD9m7rmzI7dKeI+YqhArUT1M=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=crpF10QQqsr20Er9vFhNPz4YZSdopFHGO79+dvswEUD0sIgvvT3c+mrpG9WiqUo+fflRPM0JRjYiicHbWdh7RA0FPMeOQb+3JU2C5rlqEEnlLEcampDvU4/0IiAlyD3Or/tKQhwhtalqUMFk7mjLv+3flBxpYe3HXAJcf+AcxNk= ARC-Authentication-Results: i=2; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=bachmann.info header.i=@bachmann.info header.a=rsa-sha256 header.s=selector1 header.b=MtiUEDCV DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B2DF74BA2E09 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=si4KpD/TXvV3c34eLSvueEPX11GjKSZsbxY42WRFBkFnlqovyX+6wktXV+32V6Lh9BxpO+xvtu+PthVEl0ghXlAOyGS+K8FVYNtkS/wsGO0jXvGTDp/8RjhrhjcfiWLH9qp9cE/XNoraXTDXDJcL7oiVUhP2i6OHaMDva2taoAak2mCHkYrK/ZDFpK2fV+e9OeVHEgclLhrsiDNruRPPQthUd6mz086NoBu+Xfwd1ShCVzt6aoBi9Qy7/ekH2krTUgDUyP6f9Ago7sUm8p7pKItF3k1xJXv1JQThmtRlWTxiaGmIFBA+NvOK0qyKceDUZL85P5Wo4X6cioJsSuzyLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=meDJkuKDyYhRpdgtPGy0HTx2LCNLv4V4QCDiq3U2QJA=; b=JqHMNFrwh2dg0kFXhAF1fk7B1HKI5auezu+8BiAw+lHYp1oJH9NUpSNyIxaPSD703LOy5dLnIeXmoEmt0DQ2X7gwRtF6QUNdkneYJ25Guxz61Quo4YyaKffFSvRdFfcGCmECqnq3u+3Av7Cnnh0zs5UdFET/oCPqmmG4+n4NnLICjqH9cYtEy+a2j0jbZuRI11YL8ROSGGz9G3xbwqWKFqKpzXdlOCW1OioR5BMh7/ipHx+eI71IvFca02LEzO+GRVi0jskUHLrxX63JUOv123JSYdeWOmsgfXSx0110D6gTyXp9i1T46nBro7naVu95/M1VQaPLrsA9mOXSAlAtuw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 185.67.228.71) smtp.rcpttodomain=sourceware.org smtp.mailfrom=bachmann.info; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=bachmann.info; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bachmann.info; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=meDJkuKDyYhRpdgtPGy0HTx2LCNLv4V4QCDiq3U2QJA=; b=MtiUEDCVqghkm/nCGA/y044jMTWazRHEY9ffLa1as6CW9fREaTIAvqBUAUZcwVfnnRot6Lk4WGDcq88ppoGQvI323SAQPz+U9XQYIPUF2KVhxqFVmZ/Bq/W9Dfs85pmo+ro3MFzuO+TcCY9n70Fg0ARyZ3u+gYjin4A3WwETjTA= Received: from CWLP265CA0498.GBRP265.PROD.OUTLOOK.COM (2603:10a6:400:18b::12) by DB8PR05MB6796.eurprd05.prod.outlook.com (2603:10a6:10:13c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.113.13; Thu, 11 Jun 2026 05:37:18 +0000 Received: from AMS0EPF00000197.eurprd05.prod.outlook.com (2603:10a6:400:18b:cafe::a2) by CWLP265CA0498.outlook.office365.com (2603:10a6:400:18b::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.113.13 via Frontend Transport; Thu, 11 Jun 2026 05:37:18 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 185.67.228.71) smtp.mailfrom=bachmann.info; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=bachmann.info; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning bachmann.info discourages use of 185.67.228.71 as permitted sender) Received: from webmail.bachmann.info (185.67.228.71) by AMS0EPF00000197.mail.protection.outlook.com (10.167.16.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.113.7 via Frontend Transport; Thu, 11 Jun 2026 05:37:17 +0000 Received: from ATFKPCLXMAKO.bachmann.at (10.204.44.221) by atfkex03.bachmann.at (10.10.10.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Thu, 11 Jun 2026 07:37:17 +0200 From: Martin KOCH To: CC: Martin KOCH Subject: [PATCH] gdb/remote: fix assertions when attaching in non-stop mode Date: Thu, 11 Jun 2026 07:36:42 +0200 Message-ID: <20260611053642.3893794-1-Martin.KOCH@bachmann.info> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: atfkex03.bachmann.at (10.10.10.31) To atfkex03.bachmann.at (10.10.10.31) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF00000197:EE_|DB8PR05MB6796:EE_ X-MS-Office365-Filtering-Correlation-Id: ceb7e057-33ae-470d-5c6b-08dec77b8012 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700016|376014|82310400026|1800799024|23010399003|18002099003|13003099007|11063799006|56012099006; X-Microsoft-Antispam-Message-Info: JxcjfqaezvnB5C+Sm+6JA7/yEOA19T1AKybHYcIXUfQzBFq5AlnivJPiM/bQ0eP41sy905mM88aU+6Mkh8jhd74HdYrX82+1iCfWTX4j/BtUXObWVG8yPL6/hQIz1IE4ALAi6uzfpVKeP+6+23QP8Rw0Ko+JnH3JfdU4uFrpzW57KgWJIZCjAqQeffYTVQ11JY996LAYvZ4xligq53E+zWnSprdkkgY3fxTBU0t9hFFo9cKCinpGEzYjZ7hRtJAGlbfpYB59UldMGACUA/RKm3as5tw1UzhKTbZpuMmL2pa2lzInbRhP/N3lYrT1bSlUWjVAavjxBfyQW4RT13Y3EKZRzD8kL9Zoesd0AivExpL4I2l4Sx9N6blfyNp5zUEkMVRu/1DphaOaGOHnPwVkq36lJ3FCV7fh6fnaDsrIjdS3QfY8sDvzMyJWa9d2e2GMyPuxOt+m1w3LnZnd4WDB45Zl9B+YtzOm75MyYsRu52xpf8DLsgzsJczN4c0/hTHDfWT98jxkBd5FgLzLXUeQrRBzCd+WVh07aKoYl2engCE1g12aVl0UX6UdlK8l7u955idwcQixbPw80ovioMK7Y6qgkmTSN2IMpuDlqFVQyCHCxvPYLcN3EcLowr+BiPM8PkEanDKEUCOEtF3qqZVSpqLedzS+pqnp52VsJXraaAMQLUE5l8HKafk31VQMfhbDNA+liCPlsb/EYihUM/5DvknuX+FxMWxUO8hWYPbGypg= X-Forefront-Antispam-Report: CIP:185.67.228.71; CTRY:AT; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:webmail.bachmann.info; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700016)(376014)(82310400026)(1800799024)(23010399003)(18002099003)(13003099007)(11063799006)(56012099006); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bilQrN+mUzga+ihHgAPHqL49ozT1ReVckC/Rw1fDHlH3+akrbvhYOZX/h8T8Hbvh/rUTT1IYIhH4m4uhy1QcKZytAxdRIMHF/x14L8uw6wyJF+6IVDE0oaHDDCXXwv3ZtYPGIrAtbjLQ3n5iZ6HrytRAt6iI5qrGBLs5jTkBGCitYjNvlAI8z4+fMyJ48JLbzLbE7n1eErhAPMt9qrKACHV3djlmP3Dq22lZWaoufRL/ZLMcGLnGU7Gpy21/yyYGA5qKMyssP2yoHAACMNG7UP0i/f61em2a55b2yczaqhz97IhfbR/6p7eOL4F2H9XmvJWrwWAir9TesF2ak/7AvViZwyBgOAiH3vA1Dw87N0/cl919wHc2pCHZ8/iJR2XRBARqTqWMf43hVeuvPXU7+k8HEmhleUIIPprve1WJFw3wWyOAOmGvDiaYdXkHgjXC X-OriginatorOrg: bachmann.info X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2026 05:37:17.6087 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ceb7e057-33ae-470d-5c6b-08dec77b8012 X-MS-Exchange-CrossTenant-Id: e3bace4d-d2e7-4d8f-afb8-152509ee3f1a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e3bace4d-d2e7-4d8f-afb8-152509ee3f1a; Ip=[185.67.228.71]; Helo=[webmail.bachmann.info] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF00000197.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR05MB6796 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org When connecting to a remote target in non-stop mode against a multi-threaded inferior stopped at raise(SIGSTOP), three internal-error assertions can fire in sequence: remote.c:546: mark_async_event_handler: Assertion 'this->is_async_p ()' failed. thread.c:429: set_pending_waitstatus: Assertion 'this->internal_state () == THREAD_INT_STOPPED || ...' failed. thread.c:426: set_pending_waitstatus: Assertion '!this->has_pending_waitstatus ()' failed. The first one is what PR 30630 reports and is fixed with the PR proposed by Mikhail Terekhov, but with the fix the two other assertions surface: * thread.c:429: addressed by reordering set_internal_state / set_state to run before set_pending_waitstatus. * thread.c:426: addressed by clearing any existing pending wait status before installing the new one, when gdbserver delivers multiple events for the same thread. [1] https://sourceware.org/pipermail/gdb-patches/2023-October/202937.html Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30630 Signed-off-by: Martin KOCH --- gdb/remote.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index 2961664cf33..4148301bc6f 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -5237,13 +5237,17 @@ remote_target::process_initial_stop_replies (int from_tty) ws.set_stopped (sig); } - if (ws.kind () != TARGET_WAITKIND_STOPPED - || ws.sig () != GDB_SIGNAL_0) - evthread->set_pending_waitstatus (ws); - set_internal_state (this, event_ptid, THREAD_INT_STOPPED); set_state (this, event_ptid, THREAD_STOPPED); get_remote_thread_info (evthread)->set_not_resumed (); + + if (ws.kind () != TARGET_WAITKIND_STOPPED + || ws.sig () != GDB_SIGNAL_0) + { + if (evthread->has_pending_waitstatus ()) + evthread->clear_pending_waitstatus (); + evthread->set_pending_waitstatus (ws); + } } /* "Notice" the new inferiors before anything related to @@ -8384,7 +8388,7 @@ remote_target::queued_stop_reply (ptid_t ptid) remote_state *rs = get_remote_state (); stop_reply_up r = remote_notif_remove_queued_reply (ptid); - if (!rs->stop_reply_queue.empty () && target_can_async_p ()) + if (!rs->stop_reply_queue.empty () && target_is_async_p ()) { /* There's still at least an event left. */ rs->mark_async_event_handler (); -- 2.43.0