From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id CQWpIRD12GpROwYAWB0awg (envelope-from ) for ; Wed, 21 Oct 2026 13:23:28 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=qTnDTETh; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id B3FB31E04D; Wed, 21 Oct 2026 13:23:27 -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.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET, 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 822511E04D for ; Wed, 21 Oct 2026 13:23:22 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CC7474BA23FD for ; Wed, 21 Oct 2026 17:23:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CC7474BA23FD Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=qTnDTETh Received: from omta40.uswest2.a.cloudfilter.net (omta40.uswest2.a.cloudfilter.net [35.89.44.39]) by sourceware.org (Postfix) with ESMTPS id 81B134BA23F8 for ; Wed, 21 Oct 2026 17:22:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 81B134BA23F8 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 81B134BA23F8 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=35.89.44.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792603364; cv=none; b=F+BHDtpcm1NSsUz0rXgf6VrnMrgr5x7kRiZeysMJgLJqHiAi7kRHL63rrMNIsdeZ32wgmnHtxpi63KqSqr7xOmeIYTjRp7S1fPPLkN3HDrlU4M8EnASUDzKEFSGiX7OREZ3XEAC20ibEtjwCCsFEVVk1KCYPJLB2Wekeq7NWhDs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792603364; c=relaxed/simple; bh=n4l98yETmNMGapdrMssIINKZQIXwz5GuNj1M1inQ/5c=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Ga3kQmOBEVDpBBTT8QELhL0/mRVS6Eyr4DmK8AiDwoI9Dv76Z/fprV1wJpZniCKMp+nTrJWkf3/vvrw92U8j+vZ1kLqKlHo4oM/hr5QVPYAdsJ6RoZB4wlbZ7ApbZCXGSJsfNJvJ7m2Lg1HhZ1Zs0U10SEWobsmWDBJPUUnwLIg= ARC-Authentication-Results: i=1; sourceware.org; dkim=policy (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=qTnDTETh reason="signing key too small" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 81B134BA23F8 Received: from eig-obgw-6001b.ext.cloudfilter.net ([10.0.30.143]) by cmsmtp with ESMTPS id JYRuxpz0Xc3XsJa1TxutNh; Wed, 21 Oct 2026 17:22:43 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id Ja1SxRHW4AJ7UJa1Sx1cZA; Wed, 21 Oct 2026 17:22:42 +0000 X-Authority-Analysis: v=2.4 cv=UphjN/wB c=1 sm=1 tr=0 ts=6ad8f4e2 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=660iZSQnnn4A:10 a=ItBw4LHWJt0A:10 a=QyXUC8HyAAAA:8 a=q-_5BsYpWFi_TGgDQVcA:9 a=DCx65vhANUyCzuf5D8fC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To :Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=axdwLVkNU3cgkAO6Y5tq/CLJ6kSPSuu86qURTO6s95k=; b=qTnDTEThE3K9JXR27pKb2VdGg1 ROr9SKpsaUG5a6K1Wp9cNnzUob8IBMIgrXwD8/ZdLYWm5ztso0KgUP3MAehNE1ZJ7fNqKRMxPzUEU /xtNZKJiSHGZ/iO5F8HCSKnSR; Received: from 97-122-110-129.hlrn.qwest.net ([97.122.110.129]:58338 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xJa1R-00000003bwI-3Kdh; Wed, 21 Oct 2026 11:22:41 -0600 From: Tom Tromey To: "Rohr, Stephan" Cc: Tom Tromey , "gdb-patches@sourceware.org" , "guinevere@redhat.com" Subject: Re: [PATCH vv2 1/1] gdb: fix assert after register write failure In-Reply-To: (Stephan Rohr's message of "Wed, 21 Oct 2026 13:47:56 +0000") References: <20261015141127.152846-1-stephan.rohr@intel.com> <20261015141127.152846-2-stephan.rohr@intel.com> <87o6cp1x4x.fsf@tromey.com> X-Attribution: Tom Date: Wed, 21 Oct 2026 11:22:40 -0600 Message-ID: <87zew7x927.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.110.129 X-Source-L: No X-Exim-ID: 1xJa1R-00000003bwI-3Kdh X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-110-129.hlrn.qwest.net (bapiya) [97.122.110.129]:58338 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfMoVYxzeMyGSn0Krb8K6rsaEL5mnR4Pw2rr/LQtEVx+5uDk8F9ctKAUKeBfMSb1h2hxBYPznyoO2Ny0hBXV8hjNw9mklqDQKyTudGzZHel2S2Q19tskh +1d4jILp+ZZfWCbG/pz9zPaiVntg5J8GhoH6qmu5QaR67Ti1cDQA5HjlcLRhQ54U4RKOHSWAssev0PTDqTnPxro1EsGgW4s4kzY= 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 >>>>> Rohr, Stephan writes: > m_register_status is never reset in regcache.c itself. The bug is exposed in > regcache::raw_write: > 2. If the remote connection dies in "target_store_registers", the regcache is > deleted. This deletes the register buffers and the register status buffer. > I was able to manually reproduce the bug: Thanks. I reproduced it locally with your instructions. I think the problem here is in step 2 -- the invalidator is accessing 'this' but this object has been destroyed. That is, I set a breakpoint where the invalidator is made and: (top-gdb) p this $1 = (regcache * const) 0x2f8f4d0 and then I set a breakpoint in ~regcache and "next"d over the call to target_store_registers: (top-gdb) break regcache::~regcache Breakpoint 4 at 0xb9e722: regcache::~regcache. (2 locations) (top-gdb) n Thread 1 "gdb" hit Breakpoint 4.2, regcache::~regcache (this=0x2f8f4d0) at ../../binutils-gdb/gdb/regcache.h:370 ... with the backtrace looking like: (top-gdb) bt #0 regcache::~regcache (this=0x2f8f4d0) at ../../binutils-gdb/gdb/regcache.h:370 [... lots of stuff ...] #32 0x0000000000d75522 in target_store_registers (regcache=0x2f8f4d0, regno=0) at ../../binutils-gdb/gdb/target.c:3935 #33 0x0000000000b9818e in regcache::raw_write (this=0x2f8f4d0, regnum=0, src=...) at ../../binutils-gdb/gdb/regcache.c:889 I think what this means is that the invalidator here has a use-after-free. So I tend to think your patch also does this, and it would be exposed by an ASAN build. > An alternative for the nullptr check could be implemented by moving > the call of "target_store_registers ()" into a try block and invalidate > in "catch" if the error is not a "TARGET_CLOSE_ERROR". > Does this sound reasonable? I think so. The key thing is that if 'this' is destroyed by the operation, then it cannot be used again. If TARGET_CLOSE_ERROR is the only such case then that's fine. It's possible the problem lies elsewhere, I'm afraid I am not really certain. thanks, Tom