public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/30249] New: upgrade the GDB to 13.1 version, hookpost-extended-remote will not work.
@ 2023-03-20  8:57 wenyan.xin at windriver dot com
  2023-03-20  8:59 ` [Bug gdb/30249] " wenyan.xin at windriver dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: wenyan.xin at windriver dot com @ 2023-03-20  8:57 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 30249
           Summary: upgrade the GDB to 13.1 version,
                    hookpost-extended-remote will not work.
           Product: gdb
           Version: 13.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: wenyan.xin at windriver dot com
  Target Milestone: ---

upgrade the GDB to 13.1 version, hookpost-extended-remote will not work.


GNU gdb (GDB) 14.0.50.20230320-git
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) define target hookpost-extended-remote
Type commands for definition of "target hookpost-extended-remote".
End with a line saying just "end".
>echo hookpost-extended-remote\n
>end
(gdb) target extended-remote 127.0.0.1:2345
Remote debugging using 127.0.0.1:2345

please note here: after issue target extended-remote 127.0.0.1:2345, the
"hookpost-extended-remote; string didnot echo.


this issue exist on version 13.1 and later.

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/30249] upgrade the GDB to 13.1 version, hookpost-extended-remote will not work.
  2023-03-20  8:57 [Bug gdb/30249] New: upgrade the GDB to 13.1 version, hookpost-extended-remote will not work wenyan.xin at windriver dot com
@ 2023-03-20  8:59 ` wenyan.xin at windriver dot com
  2023-03-20  8:59 ` wenyan.xin at windriver dot com
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: wenyan.xin at windriver dot com @ 2023-03-20  8:59 UTC (permalink / raw)
  To: gdb-prs

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

wenyan.xin at windriver dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P1

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/30249] upgrade the GDB to 13.1 version, hookpost-extended-remote will not work.
  2023-03-20  8:57 [Bug gdb/30249] New: upgrade the GDB to 13.1 version, hookpost-extended-remote will not work 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
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: wenyan.xin at windriver dot com @ 2023-03-20  8:59 UTC (permalink / raw)
  To: gdb-prs

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

wenyan.xin at windriver dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wenyan.xin at windriver dot com

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/30249] upgrade the GDB to 13.1 version, hookpost-extended-remote will not work.
  2023-03-20  8:57 [Bug gdb/30249] New: upgrade the GDB to 13.1 version, hookpost-extended-remote will not work 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
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jan at vrany dot io @ 2023-03-29 13:17 UTC (permalink / raw)
  To: gdb-prs

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

Jan Vrany <jan at vrany dot io> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jan at vrany dot io

--- Comment #1 from Jan Vrany <jan at vrany dot io> ---
I can reproduce the bug and created a tentative fix, see

https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=f48f80529710f7dc9a87c6821315b7a1fa66853e

I'll run it through my CI and eventually submit.

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/30249] upgrade the GDB to 13.1 version, hookpost-extended-remote will not work.
  2023-03-20  8:57 [Bug gdb/30249] New: upgrade the GDB to 13.1 version, hookpost-extended-remote will not work wenyan.xin at windriver dot com
                   ` (2 preceding siblings ...)
  2023-03-29 13:17 ` jan at vrany dot io
@ 2023-05-19 12:38 ` cvs-commit at gcc dot gnu.org
  2023-05-20  0:27 ` tromey at sourceware dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-19 12:38 UTC (permalink / raw)
  To: gdb-prs

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.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/30249] upgrade the GDB to 13.1 version, hookpost-extended-remote will not work.
  2023-03-20  8:57 [Bug gdb/30249] New: upgrade the GDB to 13.1 version, hookpost-extended-remote will not work wenyan.xin at windriver dot com
                   ` (3 preceding siblings ...)
  2023-05-19 12:38 ` cvs-commit at gcc dot gnu.org
@ 2023-05-20  0:27 ` tromey at sourceware dot org
  2023-05-20  0:27 ` tromey at sourceware dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: tromey at sourceware dot org @ 2023-05-20  0:27 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org

--- Comment #3 from Tom Tromey <tromey at sourceware dot org> ---
Could you "git cherry-pick -x" this to the gdb 13 branch?

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/30249] upgrade the GDB to 13.1 version, hookpost-extended-remote will not work.
  2023-03-20  8:57 [Bug gdb/30249] New: upgrade the GDB to 13.1 version, hookpost-extended-remote will not work wenyan.xin at windriver dot com
                   ` (4 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: tromey at sourceware dot org @ 2023-05-20  0:27 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.2

--- Comment #4 from Tom Tromey <tromey at sourceware dot org> ---
Optimistically setting the target milestone.

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/30249] [13 regression] hookpost-extended-remote will not work
  2023-03-20  8:57 [Bug gdb/30249] New: upgrade the GDB to 13.1 version, hookpost-extended-remote will not work wenyan.xin at windriver dot com
                   ` (5 preceding siblings ...)
  2023-05-20  0:27 ` tromey at sourceware dot org
@ 2023-05-20  7:06 ` sam at gentoo dot org
  2023-05-20 19:45 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: sam at gentoo dot org @ 2023-05-20  7:06 UTC (permalink / raw)
  To: gdb-prs

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

Sam James <sam at gentoo dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|upgrade the GDB to 13.1     |[13 regression]
                   |version,                    |hookpost-extended-remote
                   |hookpost-extended-remote    |will not work
                   |will not work.              |
                 CC|                            |sam at gentoo dot org

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/30249] [13 regression] hookpost-extended-remote will not work
  2023-03-20  8:57 [Bug gdb/30249] New: upgrade the GDB to 13.1 version, hookpost-extended-remote will not work wenyan.xin at windriver dot com
                   ` (6 preceding siblings ...)
  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
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-20 19:45 UTC (permalink / raw)
  To: gdb-prs

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

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

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

commit bcd95b84d3045aef8ec50c019d7d9d4d0d5f3817
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>
    (cherry picked from commit b69378ced6a2db6adfbea9974a246a65d931bab2)

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/30249] [13 regression] hookpost-extended-remote will not work
  2023-03-20  8:57 [Bug gdb/30249] New: upgrade the GDB to 13.1 version, hookpost-extended-remote will not work wenyan.xin at windriver dot com
                   ` (7 preceding siblings ...)
  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
  9 siblings, 0 replies; 11+ messages in thread
From: jan at vrany dot io @ 2023-05-20 19:50 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #6 from Jan Vrany <jan at vrany dot io> ---
(In reply to Tom Tromey from comment #3)
> Could you "git cherry-pick -x" this to the gdb 13 branch?

I did that, run the test suite and pushed. Hope all is all right.

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/30249] [13 regression] hookpost-extended-remote will not work
  2023-03-20  8:57 [Bug gdb/30249] New: upgrade the GDB to 13.1 version, hookpost-extended-remote will not work wenyan.xin at windriver dot com
                   ` (8 preceding siblings ...)
  2023-05-20 19:50 ` jan at vrany dot io
@ 2023-05-24 18:48 ` tromey at sourceware dot org
  9 siblings, 0 replies; 11+ messages in thread
From: tromey at sourceware dot org @ 2023-05-24 18:48 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from Tom Tromey <tromey at sourceware dot org> ---
Looks great, going to close this.

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-05-24 18:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-20  8:57 [Bug gdb/30249] New: upgrade the GDB to 13.1 version, hookpost-extended-remote will not work 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
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

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).