From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SbBzNPubS2pKvCkAWB0awg (envelope-from ) for ; Mon, 06 Jul 2026 08:13:47 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=L305+sHl; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id D30FF1E098; Mon, 06 Jul 2026 08:13:47 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,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 [IPv6:2620:52:6:3111::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 6CD0C1E070 for ; Mon, 06 Jul 2026 08:13:47 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 888834BA23C6 for ; Mon, 6 Jul 2026 12:13:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 888834BA23C6 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=L305+sHl Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) by sourceware.org (Postfix) with ESMTPS id 1438B4BA2E16 for ; Mon, 6 Jul 2026 12:12:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1438B4BA2E16 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1438B4BA2E16 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783339951; cv=none; b=oHz5A3SHtQScnhlQ+YOQuvbD3nH1Wlvj/sKx3GaH5HrLBtrCubwSl5rAWzhowYrIxayCHQuDPfu8WSt2fYwdV9xJAk3FQMIORqdF8WjmEwoFygIS+qa2TkEWVuC7KV3QSoHG0iaC9a81LEqQm5e//O/cT+eEtmooKZdp46K8p6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783339951; c=relaxed/simple; bh=iZrXUwu65vCjbfR3j1s9lYN41SQGmmwJv4l2IF6+KW0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=GzHbJltRxvP9i7HHMSiUg/VGIS3QFbfVadRr/5IsIPHePWFbApHh/vhfS0z1cBoQExYEG8hPDKpt9YyiV+2sFmivOEiZM9DNUq14z3jV7q3tyZxv4hUdofSKIG5np2lhFZYSJFy06BYfQJfR6SKsFBt/O6OHf5LYGYhQbCINRTw= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=L305+sHl DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1438B4BA2E16 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1783339951; x=1814875951; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iZrXUwu65vCjbfR3j1s9lYN41SQGmmwJv4l2IF6+KW0=; b=L305+sHlZZ44i/a0/LIQtyNtBNUrJysL/5DidWyl5IgZQWj9nD6FTBr2 blacIScsmg7fvShYphUjwydgx8XDxy9H3rxoXv/jiuOfU6buzcQlxR6a1 9cq2Nnz4BzAOZjgoQ+t0dHUy0yMJchrmjdCISKa8KqYTXPT9V6NeIn4he U2CSWfdXpHT7HXWTMofMLAbpp3DDTG6QCvnfFhEX4hLhJKjEw5p3+qg/x VN9jv6NuDRzYa/3OIGtXcuG2GYZ5/tN4fMQVZny0S4MQUfAewrog9D/f3 iyCyo5UAOAT/f3UYsdbQ89rwIXGNCgto1NvC7Wf4jDlYM8D+0mvTKhkdB A==; X-CSE-ConnectionGUID: bdZoW1i6SeyVOY7UKt0wFg== X-CSE-MsgGUID: 62ok//xGTAKIp1XPcYLBnA== X-IronPort-AV: E=McAfee;i="6800,10657,11838"; a="83834515" X-IronPort-AV: E=Sophos;i="6.25,149,1779174000"; d="scan'208";a="83834515" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2026 05:12:30 -0700 X-CSE-ConnectionGUID: lkwZQzvkQvOQA/30UMzlyw== X-CSE-MsgGUID: f6wsYJavTc+84Vf50xrH4w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,149,1779174000"; d="scan'208";a="255637891" Received: from unknown (HELO localhost) ([10.245.114.180]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2026 05:12:28 -0700 From: Mohamed Bouhaouel To: gdb-patches@sourceware.org Cc: stephan.rohr@intel.com, markus.t.metzger@intel.com, pedro@palves.net, aburgess@redhat.com Subject: [PATCH v3 02/11] gdb, remote: fix assertion on reconnect to non-stop target Date: Mon, 6 Jul 2026 14:11:15 +0200 Message-ID: <20260706121124.18784-3-mohamed.bouhaouel@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260706121124.18784-1-mohamed.bouhaouel@intel.com> References: <20260706121124.18784-1-mohamed.bouhaouel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 From: "Bouhaouel, Mohamed" When reconnecting to a non-stop remote target, threads may retain stale internal state from the previous connection (e.g., THREAD_INT_RUNNING). This causes an assertion failure in thread_info::set_pending_waitstatus(), which requires the thread to be in THREAD_INT_STOPPED or THREAD_INT_RESUMED_PENDING_STATUS state. Fix by setting thread's states before calling set_pending_waitstatus () in process_initial_stop_replies (). Scenario: - Connect to non-stop remote target with running threads. - Disconnect (threads remain in THREAD_INT_RUNNING state). - Reconnect to same target. - process_initial_stop_replies() processes stop events. - Assertion fails when trying to set pending waitstatus on thread still marked as THREAD_INT_RUNNING. Reproducible when running gdb.server/reconnect-ctrl-c.exp, on native-gdbserver or native-extended-gdbserver with target-non-stop enabled. export GDBFLAGS="-iex \"maint set target-non-stop on\"" make check TESTS="gdb.server/reconnect-ctrl-c.exp" \ RUNTESTFLAGS="--target_board=native-gdbserver GDBFLAGS='$GDBFLAGS'" --- gdb/remote.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index 33222346d06..caf0579e94e 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -5177,12 +5177,13 @@ remote_target::process_initial_stop_replies (int from_tty) ws.set_stopped (sig); } + set_internal_state (this, event_ptid, THREAD_INT_STOPPED); + set_state (this, event_ptid, THREAD_STOPPED); + 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 (); } -- 2.43.0 Intel Deutschland GmbH Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany Tel: +49 89 991 430, www.intel.de Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell Chairperson of the Supervisory Board: Nicole Lau Registered Seat: Munich Commercial Register: Amtsgericht Muenchen HRB 186928