public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/30249] upgrade the GDB to 13.1 version, hookpost-extended-remote will not work.
Date: Fri, 19 May 2023 12:38:56 +0000	[thread overview]
Message-ID: <bug-30249-4717-0Fg8vQSMVn@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-30249-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=30249

--- Comment #2 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jan Vrany <jv@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b69378ced6a2db6adfbea9974a246a65d931bab2

commit b69378ced6a2db6adfbea9974a246a65d931bab2
Author: Jan Vrany <jan.vrany@labware.com>
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-remote".

    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=1) at
target.c:2483
            #2  0x000055555711e911 in remote_target::open_1
(name=0x55555881c7fe ":1234", from_tty=1, extended_p=0)
                at remote.c:5946
            #3  0x000055555711d577 in remote_target::open (name=0x55555881c7fe
":1234", from_tty=1) at remote.c:5272
            #4  0x00005555573062f2 in open_target (args=0x55555881c7fe ":1234",
from_tty=1, command=0x5555589d0490)
                at target.c:853
            #5  0x0000555556ad22fa in cmd_func (cmd=0x5555589d0490,
args=0x55555881c7fe ":1234", from_tty=1)
                at cli/cli-decode.c:2737
            #6  0x00005555573487fd in execute_command (p=0x55555881c802 "4",
from_tty=1) 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=30249

    Approved-By: Tom Tromey <tom@tromey.com>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2023-05-19 12:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-20  8:57 [Bug gdb/30249] New: " wenyan.xin at windriver dot com
2023-03-20  8:59 ` [Bug gdb/30249] " wenyan.xin at windriver dot com
2023-03-20  8:59 ` wenyan.xin at windriver dot com
2023-03-29 13:17 ` jan at vrany dot io
2023-05-19 12:38 ` cvs-commit at gcc dot gnu.org [this message]
2023-05-20  0:27 ` tromey at sourceware dot org
2023-05-20  0:27 ` tromey at sourceware dot org
2023-05-20  7:06 ` [Bug gdb/30249] [13 regression] " sam at gentoo dot org
2023-05-20 19:45 ` cvs-commit at gcc dot gnu.org
2023-05-20 19:50 ` jan at vrany dot io
2023-05-24 18:48 ` tromey at sourceware dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-30249-4717-0Fg8vQSMVn@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).