From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id oVwrD5/VKmqOswEAWB0awg (envelope-from ) for ; Thu, 11 Jun 2026 11:34:55 -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=gyPpVxNm; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 3978A1E098; Thu, 11 Jun 2026 11:34:55 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.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,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED 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 197361E070 for ; Thu, 11 Jun 2026 11:34:54 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D05D64BA23D3 for ; Thu, 11 Jun 2026 15:34:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D05D64BA23D3 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=gyPpVxNm Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by sourceware.org (Postfix) with ESMTPS id 93C824BA23C4 for ; Thu, 11 Jun 2026 15:34:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 93C824BA23C4 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=tempfail smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 93C824BA23C4 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1781192040; cv=none; b=Eg51JxN/rUItSPTjNjtpeMlxe3938n+Mg9Q/nQwT2Ugr6WR/SlytXP1zhidw5kdWWk/AmludkagbBKPJj28hpT6FyX8lW5F6azcL/E8auCZV8MaaSgb/pBO4iUsPeUyNPxv0q7UvfQPJWqBjYz2etGrJc4Se1jZ+9kNopUJmAPE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1781192040; c=relaxed/simple; bh=YW0LMpYPcMK/+097HN2mPB6Qg2hl2Tr3W70LGJqbhJU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=YmyeSfXU/y5f9mCxTsrCwCHbCaDTEFug/mLNdqD3GBW7MEHFjOHCtbTUy2Zsn5EDTQQRZQ++WHQy/NEetqZNqZ/m0rMsfCCTB92u1GPnjBtUajKYuMBllYxZJHPsBFhABmBN1bUFWDIry76qApr7WbtZr466j9sSpvqtXn3smMI= 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=gyPpVxNm DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 93C824BA23C4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1781192041; x=1812728041; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YW0LMpYPcMK/+097HN2mPB6Qg2hl2Tr3W70LGJqbhJU=; b=gyPpVxNmHJos0vGbgXdM8iFuDgp9KcDqH2KDJ/ubAYHnQvd/MCrkXTL0 GFF52D5jkOZV8xrixUiFv7VTcYMz/+kU8aWw5Bt4FSo8NIUZ0Q7CPrGta jP9zIheZjRDjBEIXkA1erOLpOe/d0X+kZoWLqS3L/OVyJudfTjzThl+l5 0PqqbNOa0XRS+dsmV15pJD+neHa1V7G7/dvIMWoCkiLZCNxYK/r0tNDi5 V602ECDUVmnQpkxeUeRq3xpIfWzWlEHSaLDEkDaczwr9p1jr9afrA7Z1Q guNKq04XbrLXhOtshGOg4IF81oxMk78BHhihoaZ/o72lRaj/h5PPOKBFo g==; X-CSE-ConnectionGUID: +URFdgQ2QCqfFZpeo5gGxA== X-CSE-MsgGUID: EYWEdO4YTd2R3YMtUGyMHw== X-IronPort-AV: E=McAfee;i="6800,10657,11813"; a="99430878" X-IronPort-AV: E=Sophos;i="6.24,199,1774335600"; d="scan'208";a="99430878" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2026 08:34:00 -0700 X-CSE-ConnectionGUID: h1w+pVJGQNO2HpA0ZyAkzg== X-CSE-MsgGUID: Uzd79/MlRU2bSopHSOwYNw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,199,1774335600"; d="scan'208";a="244071094" Received: from womilian-mobl.ger.corp.intel.com (HELO localhost) ([10.245.82.28]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2026 08:33:57 -0700 From: Mohamed Bouhaouel To: gdb-patches@sourceware.org Cc: markus.t.metzger@intel.com, stephan.rohr@intel.com, aburgess@redhat.com, mohamed.bouhaouel@intel.com Subject: [PATCH v2 02/11] gdb, remote: fix assertion on reconnect to non-stop target Date: Thu, 11 Jun 2026 17:32:22 +0200 Message-ID: <20260611153232.3011-3-mohamed.bouhaouel@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260611153232.3011-1-mohamed.bouhaouel@intel.com> References: <20260611153232.3011-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 5443864ced7..ab6fa8d3490 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -5237,12 +5237,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