From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 041703857C7E; Mon, 30 Nov 2020 15:00:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 041703857C7E From: "palves at redhat dot com" To: gdb-prs@sourceware.org Subject: [Bug remote/26614] AddressSanitizer: heap-use-after-free of extended_remote_target in remote_async_inferior_event_handler Date: Mon, 30 Nov 2020 15:00:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: remote X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: palves at redhat dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Nov 2020 15:00:58 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D26614 --- Comment #20 from Pedro Alves --- target_ops is reference counted. Wouldn't this patch fix the issue? diff --git c/gdb/remote.c w/gdb/remote.c index 71f814efb36..5a5ac1ee92f 100644 --- c/gdb/remote.c +++ w/gdb/remote.c @@ -14174,9 +14174,13 @@ remote_async_serial_handler (struct serial *scb, v= oid *context) static void remote_async_inferior_event_handler (gdb_client_data data) { + remote_target *remote =3D (remote_target *) data; + /* Hold a strong reference to the remote target while handling an + event, since that could result in closing the connection. */ + auto remote_ref =3D target_ops_ref::new_reference (remote); + inferior_event_handler (INF_REG_EVENT); - remote_target *remote =3D (remote_target *) data; remote_state *rs =3D remote->get_remote_state (); /* inferior_event_handler may have consumed an event pending on the --=20 You are receiving this mail because: You are on the CC list for the bug.=