From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4UOrFxcAVmoHiQcAWB0awg (envelope-from ) for ; Tue, 14 Jul 2026 05:23:35 -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=kYTf1ltp; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 598121E09E; Tue, 14 Jul 2026 05:23:35 -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 [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 6965B1E099 for ; Tue, 14 Jul 2026 05:23:34 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 917EA4BA2E30 for ; Tue, 14 Jul 2026 09:23:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 917EA4BA2E30 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=kYTf1ltp Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by sourceware.org (Postfix) with ESMTPS id 26D424BA2E11 for ; Tue, 14 Jul 2026 09:22:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 26D424BA2E11 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 26D424BA2E11 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784020920; cv=none; b=mpBry47uqRohsjsyGb3qxaoAJKcVH95VhAIHrPIqj7bW7mac3HVkg1rcsDDE1bYHdh4s1ZG7KV+K+wCWaaEGyFH4CV9Pfz47hxBH3kA2DoTdALdMLL+HlVVJWcK5j6COY9+2vg/FeaHDQmfW+XmajVbWP5cq2sfLsIqRiwpHKTY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784020920; c=relaxed/simple; bh=BGh15jvBCbURfV48TfqoJJ6PFUxt/geJocPPYWqQ3jo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=rB4sOeq2FRahHnKF1X1cHXRc3OaP1Zfl+3VEo2/+bBIhktI0Qf5IiQ/sxRmueIifaoKnWCY2xuHJrj/Xq3NE+Ie5RoEKQvejcXn7zfJFNBfQ/+UeYPg2LyBAOparl5ZYa121prxmbfmkvTKjvBT5iUeEuHHaeNLkem9Six/UdcY= 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=kYTf1ltp DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 26D424BA2E11 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1784020920; x=1815556920; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BGh15jvBCbURfV48TfqoJJ6PFUxt/geJocPPYWqQ3jo=; b=kYTf1ltpPrJYAfxrAuijBNGyjAkutTE8jhwGis6KiMWAk6vMczo04tK7 VMF9iCLGXO0SSU4n21dJ7iAO0YWQCZMVXnfjboZV92VY2TONCnecv7kVk V2E1/uN48oAi6ULQU+9lPBwNHnKSmI6LqZ/CKiHXDChzWkFAS6GSZfYmC qstHu78iz800oTUHJatviqs35mwSbCywqo8Ta90s4JqCe2DiOStmEpx1B OdI9crU5s/C7Tw3ySD8PK27q8J5ANf2UUH99paYVaYccuoXrjfqOSDI/3 Fuoy4twMKRuaIHYNxrExxTOfbr+rKrmXXK3zO9QStThpfiSZaisWskAe2 A==; X-CSE-ConnectionGUID: 5dJmhofRRGe6PlK+u+F2Lw== X-CSE-MsgGUID: rTq6OGH4RUuhIHbN2sJNQQ== X-IronPort-AV: E=McAfee;i="6800,10657,11846"; a="95284592" X-IronPort-AV: E=Sophos;i="6.25,163,1779174000"; d="scan'208";a="95284592" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2026 02:21:59 -0700 X-CSE-ConnectionGUID: pLPkotcSTWypPVN336dJzQ== X-CSE-MsgGUID: JdVOobYpQr6uAvDkB50NIA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,163,1779174000"; d="scan'208";a="254679396" Received: from sguenant-mobl2.ger.corp.intel.com (HELO localhost) ([10.246.18.94]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2026 02:21:57 -0700 From: Mohamed Bouhaouel To: gdb-patches@sourceware.org Cc: markus.t.metzger@intel.com, stephan.rohr@intel.com, eliz@gnu.org, aburgess@redhat.com, pedro@palves.net Subject: [PATCH v4 02/11] gdb, remote: fix assertion on reconnect to non-stop target Date: Tue, 14 Jul 2026 11:21:19 +0200 Message-ID: <20260714092128.12941-3-mohamed.bouhaouel@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260714092128.12941-1-mohamed.bouhaouel@intel.com> References: <20260714092128.12941-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 194c4cbd9bb..7022e58abab 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