From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E32FA385841D; Sat, 20 May 2023 19:45:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E32FA385841D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684611935; bh=zLxDTsaXHn0UuoEYydnfeH7yZa4al4+wlwSdKgFVMSQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XDx9C3LNgufqrrN3gz23SXL/vh+m3C1H+5llTXz6C4e9HosYTvW/g3jRr9EfbXLfk LJa+xe8HTQmlD+Xbjpw3PmcGa/x99WrIw+pCeUm7V/RxsBrE9RiTkIXbvvV1NI48qf 5VLUEw8Y6gKOfsv+Z3jJ6s3nyeWRiF+ijRE1+sis= From: "cvs-commit at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug gdb/30249] [13 regression] hookpost-extended-remote will not work Date: Sat, 20 May 2023 19:45:35 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: 13.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: 13.2 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 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30249 --- Comment #5 from cvs-commit at gcc dot gnu.org --- The gdb-13-branch branch has been updated by Jan Vrany : https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dbcd95b84d304= 5aef8ec50c019d7d9d4d0d5f3817 commit bcd95b84d3045aef8ec50c019d7d9d4d0d5f3817 Author: Jan Vrany Date: Fri May 19 13:20:04 2023 +0100 gdb: fix post-hook execution for remote targets Commit b5661ff2 ("gdb: fix possible use-after-free when executing commands") attempted to fix possible use-after-free in case command redefines itself. Commit 37e5833d ("gdb: fix command lookup in execute_command ()") updated the previous fix to handle subcommands as well by using the original command string to lookup the command again after its execution. This fixed the test in gdb.base/define.exp but it turned out that it does not work (at least) for "target remote" and "target extended-remot= e". The problem is that the command buffer P passed to execute_command () gets overwritten in dont_repeat () while executing "target remote" command itself: #0 dont_repeat () at top.c:822 #1 0x000055555730982a in target_preopen (from_tty=3D1) at target.c:2483 #2 0x000055555711e911 in remote_target::open_1 (name=3D0x55555881c7fe ":1234", from_tty=3D1, extended_p=3D0) at remote.c:5946 #3 0x000055555711d577 in remote_target::open (name=3D0x5555588= 1c7fe ":1234", from_tty=3D1) at remote.c:5272 #4 0x00005555573062f2 in open_target (args=3D0x55555881c7fe ":= 1234", from_tty=3D1, command=3D0x5555589d0490) at target.c:853 #5 0x0000555556ad22fa in cmd_func (cmd=3D0x5555589d0490, args=3D0x55555881c7fe ":1234", from_tty=3D1) at cli/cli-decode.c:2737 #6 0x00005555573487fd in execute_command (p=3D0x55555881c802 "= 4", from_tty=3D1) at top.c:688 Therefore the second call to lookup_cmd () at line 697 fails to find command because the original command string is gone. This commit addresses this particular problem by creating a *copy* of original command string for the sole purpose of using it after command execution to lookup the command again. It may not be the most efficient way but it's safer given that command buffer is shared and overwritten in hard-to-foresee situations. Tested on x86_64-linux. PR 30249 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30249 Approved-By: Tom Tromey (cherry picked from commit b69378ced6a2db6adfbea9974a246a65d931bab2) --=20 You are receiving this mail because: You are on the CC list for the bug.=