From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4VMqM+b/VWoHiQcAWB0awg (envelope-from ) for ; Tue, 14 Jul 2026 05:22:46 -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=bjr5rsig; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id CA0DA1E09E; Tue, 14 Jul 2026 05:22:46 -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 DCB4A1E099 for ; Tue, 14 Jul 2026 05:22:45 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 39B704BA23C3 for ; Tue, 14 Jul 2026 09:22:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 39B704BA23C3 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=bjr5rsig Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by sourceware.org (Postfix) with ESMTPS id 0962D4BA2E0E for ; Tue, 14 Jul 2026 09:22:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0962D4BA2E0E 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 0962D4BA2E0E 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=1784020933; cv=none; b=L6P2Eb5Y8uLA5uvaWlg4S8Mne+vO70hPdo2VKt5GT6e9K1S9i7b/xw+RNgyNxofkAu/fA+C/PXSO6CnzNQQHRG1R9SlnimXLnLd+jdGCewyeLVFAVLKrQP1Eb7te2WfbGRkecyUB0QZvOlE6+i+vuTueHmfOb95eRr3i5EMkeYY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784020933; c=relaxed/simple; bh=/T6GIU4TfH/wpHEdfjWJA4jjvE1C8Y+8bF1uTyrOdPg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=x5Wifzb3irgXUNuHL3G1NqL8YjOHGB61gskJB4VzrYFQWyG86QdI64glGw65oTWv5mgjUq/SS3r1Z06Dq+VYgTUYiKuMfXdA9YzsF8chfsh6nJnCtirka6vbeVf01XCvqwnuUbD5KlGPloC5t/znLWSdW+re4ATm+RojDi9zQ1E= 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=bjr5rsig DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0962D4BA2E0E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1784020933; x=1815556933; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/T6GIU4TfH/wpHEdfjWJA4jjvE1C8Y+8bF1uTyrOdPg=; b=bjr5rsig7abv/gC7qJ5lqDWEBdPbGYAcG1+PONfxoWS2gX1tn2u8qseC neSmb7AZvg7tm+UDb2fauDdG8otR5EypZfyQqZNTKi0bS1FO0Cggj6wIc gbaIuxKvuGcsBgkFsHffMudUnZAY1Qy19ZVZGLNZ7EEZIC2C7x/l1l8jh 29tlguFdNNyvJmRjWMjCMOrSwkr76yUJ1ltKuOLMy6FSdK92/AB69cP6q +6RF16tZQjZZKGL3QXV+aZ8mKvYZV8ZGQI3JrZ1GaTFweg5si/bLAu9U1 HQamAk7kRWkNd6Fe7C5USzb43TZ5kjYE7hPwzY5k3ybmF+PUkcXGs3WBW A==; X-CSE-ConnectionGUID: 0A0d4ifCQzi96vdtpGXUoQ== X-CSE-MsgGUID: dGu1UcfGRRmLXP24PLcziQ== X-IronPort-AV: E=McAfee;i="6800,10657,11846"; a="95284619" X-IronPort-AV: E=Sophos;i="6.25,163,1779174000"; d="scan'208";a="95284619" 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:22:13 -0700 X-CSE-ConnectionGUID: kgXIed5xRqqZMKosod3Rhg== X-CSE-MsgGUID: i1I5CDxDTVWnDmTF9rCW0w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,163,1779174000"; d="scan'208";a="254679419" 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:22:11 -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 05/11] gdb, remote: fix crash when accessing removed events Date: Tue, 14 Jul 2026 11:21:22 +0200 Message-ID: <20260714092128.12941-6-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" Dereferencing events after calling std::remove_if causes GDB to crash because the matching unique_ptrs have been moved from and are null. Fix by logging events in std::remove_if. The bug is visible by inspection; reproducing it requires discard_pending_stop_replies to be called with matching entries in the queue and remote debug logging enabled. --- gdb/remote.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index 02fefdab067..b27b1a1b6c0 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -8254,17 +8254,20 @@ remote_target::discard_pending_stop_replies (struct inferior *inf) /* Discard the stop replies we have already pulled with vStopped. */ - auto iter = std::remove_if (rs->stop_reply_queue.begin (), - rs->stop_reply_queue.end (), - [=] (const stop_reply_up &event) - { - return event->ptid.pid () == inf->pid; - }); - for (auto it = iter; it != rs->stop_reply_queue.end (); ++it) - remote_debug_printf - ("discarding queued stop reply: ptid: %s, ws: %s\n", - (*it)->ptid.to_string().c_str(), - (*it)->ws.to_string ().c_str ()); + auto iter + = std::remove_if (rs->stop_reply_queue.begin (), + rs->stop_reply_queue.end (), + [=] (const stop_reply_up &event) + { + if (event->ptid.pid () != inf->pid) + return false; + + remote_debug_printf + ("discarding queued stop reply: ptid: %s, ws: %s\n", + event->ptid.to_string ().c_str (), + event->ws.to_string ().c_str ()); + return true; + }); rs->stop_reply_queue.erase (iter, rs->stop_reply_queue.end ()); } -- 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