public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/28093] New: set language unknown -> print "foo" -> GDB crash
@ 2021-07-15 13:41 pedro at palves dot net
  2021-07-15 13:43 ` [Bug gdb/28093] " pedro at palves dot net
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: pedro at palves dot net @ 2021-07-15 13:41 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 28093
           Summary: set language unknown -> print "foo" -> GDB crash
           Product: gdb
           Version: unknown
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: pedro at palves dot net
  Target Milestone: ---

(gdb) set language unknown 
(gdb) p "foo"
Aborted (core dumped)

Thread 1 "gdb" received signal SIGSEGV, Segmentation fault.
parse_exp_in_context (stringptr=0x7fffffffd370, pc=0x0, block=0x0, comma=0,
void_context_p=false, tracker=0x7fffffffd270, cstate=0x0) at
/home/pedro/gdb/binutils-gdb/src/gdb/parse.c:522
522       result->op->set_outermost ();

(top-gdb) p result->op
$1 = std::unique_ptr<expr::operation> = {get() = 0x0}
(top-gdb) p result
$2 = std::unique_ptr<expression> = {get() = 0x5555564dbcd0}
(top-gdb) p *result
$3 = {language_defn = 0x55555649ea90 <unknown_language_defn>, gdbarch =
0x55555659e5e0, op = std::unique_ptr<expr::operation> = {get() = 0x0}}

(top-gdb) bt
#0  parse_exp_in_context (stringptr=0x7fffffffd370, pc=0x0, block=0x0, comma=0,
void_context_p=false, tracker=0x7fffffffd270, cstate=0x0) at
/home/pedro/gdb/binutils-gdb/src/gdb/parse.c:522
#1  0x0000555555b03f20 in parse_expression (During symbol reading: .debug_line
address at offset 0x48fdc7 is 0 [in module
/home/pedro/gdb/binutils-gdb/build/gdb/gdb]
string=0x5555564db182 "\"foo\"", tracker=0x0, void_context_p=false) at
/home/pedro/gdb/binutils-gdb/src/gdb/parse.c:546
#2  0x0000555555b09762 in process_print_command_args (args=0x5555564db182
"\"foo\"", print_opts=0x7fffffffd450, voidprint=true) at
/home/pedro/gdb/binutils-gdb/src/gdb/printcmd.c:1304
#3  0x0000555555b0982d in print_command_1 (args=0x5555564db182 "\"foo\"",
voidprint=1) at /home/pedro/gdb/binutils-gdb/src/gdb/printcmd.c:1318
#4  0x0000555555b09c72 in print_command (exp=0x5555564db182 "\"foo\"",
from_tty=1) at /home/pedro/gdb/binutils-gdb/src/gdb/printcmd.c:1435
#5  0x00005555557a0164 in do_const_cfunc (c=0x55555654a610, args=0x5555564db182
"\"foo\"", from_tty=1) at
/home/pedro/gdb/binutils-gdb/src/gdb/cli/cli-decode.c:102
#6  0x00005555557a4a38 in cmd_func (cmd=0x55555654a610, args=0x5555564db182
"\"foo\"", from_tty=1) at
/home/pedro/gdb/binutils-gdb/src/gdb/cli/cli-decode.c:2160
#7  0x0000555555cbfdc2 in execute_command (p=0x5555564db186 "\"", from_tty=1)
at /home/pedro/gdb/binutils-gdb/src/gdb/top.c:674
#8  0x000055555592494b in command_handler (command=0x5555564db180 "p \"foo\"")
at /home/pedro/gdb/binutils-gdb/src/gdb/event-top.c:588
#9  0x0000555555924dd3 in command_line_handler (rl=...) at
/home/pedro/gdb/binutils-gdb/src/gdb/event-top.c:773
#10 0x0000555555cef958 in tui_command_line_handler (rl=...) at
/home/pedro/gdb/binutils-gdb/src/gdb/tui/tui-interp.c:268
#11 0x0000555555923fe4 in gdb_rl_callback_handler (rl=0x5555564dc340 "p
\"foo\"") at /home/pedro/gdb/binutils-gdb/src/gdb/event-top.c:218
#12 0x0000555555dd1342 in rl_callback_read_char () at
/home/pedro/gdb/binutils-gdb/src/readline/readline/callback.c:281
#13 0x0000555555923e00 in gdb_rl_callback_read_char_wrapper_noexcept () at
/home/pedro/gdb/binutils-gdb/src/gdb/event-top.c:176
#14 0x0000555555923eae in gdb_rl_callback_read_char_wrapper
(client_data=0x5555564daeb0) at
/home/pedro/gdb/binutils-gdb/src/gdb/event-top.c:193
#15 0x000055555592474b in stdin_event_handler (error=0,
client_data=0x5555564daeb0) at
/home/pedro/gdb/binutils-gdb/src/gdb/event-top.c:515
#16 0x0000555555f16c27 in handle_file_event (file_ptr=0x555556659160,
ready_mask=1) at /home/pedro/gdb/binutils-gdb/src/gdbsupport/event-loop.cc:575
#17 0x0000555555f171d9 in gdb_wait_for_event (block=1) at
/home/pedro/gdb/binutils-gdb/src/gdbsupport/event-loop.cc:701
#18 0x0000555555f15f84 in gdb_do_one_event () at
/home/pedro/gdb/binutils-gdb/src/gdbsupport/event-loop.cc:237
#19 0x0000555555a74503 in start_event_loop () at
/home/pedro/gdb/binutils-gdb/src/gdb/main.c:421
#20 0x0000555555a7464e in captured_command_loop () at
/home/pedro/gdb/binutils-gdb/src/gdb/main.c:481
#21 0x0000555555a760b5 in captured_main (data=0x7fffffffdb30) at
/home/pedro/gdb/binutils-gdb/src/gdb/main.c:1353
#22 0x0000555555a76127 in gdb_main (args=0x7fffffffdb30) at
/home/pedro/gdb/binutils-gdb/src/gdb/main.c:1368
#23 0x000055555563fd16 in main (argc=2, argv=0x7fffffffdc48) at
/home/pedro/gdb/binutils-gdb/src/gdb/gdb.c:32

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

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

* [Bug gdb/28093] set language unknown -> print "foo" -> GDB crash
  2021-07-15 13:41 [Bug gdb/28093] New: set language unknown -> print "foo" -> GDB crash pedro at palves dot net
@ 2021-07-15 13:43 ` pedro at palves dot net
  2021-07-15 14:47 ` tromey at sourceware dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pedro at palves dot net @ 2021-07-15 13:43 UTC (permalink / raw)
  To: gdb-prs

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

Pedro Alves <pedro at palves dot net> changed:

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

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

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

* [Bug gdb/28093] set language unknown -> print "foo" -> GDB crash
  2021-07-15 13:41 [Bug gdb/28093] New: set language unknown -> print "foo" -> GDB crash pedro at palves dot net
  2021-07-15 13:43 ` [Bug gdb/28093] " pedro at palves dot net
@ 2021-07-15 14:47 ` tromey at sourceware dot org
  2021-07-15 15:44 ` tromey at sourceware dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at sourceware dot org @ 2021-07-15 14:47 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at sourceware dot org   |tromey at sourceware dot org

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

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

* [Bug gdb/28093] set language unknown -> print "foo" -> GDB crash
  2021-07-15 13:41 [Bug gdb/28093] New: set language unknown -> print "foo" -> GDB crash pedro at palves dot net
  2021-07-15 13:43 ` [Bug gdb/28093] " pedro at palves dot net
  2021-07-15 14:47 ` tromey at sourceware dot org
@ 2021-07-15 15:44 ` tromey at sourceware dot org
  2021-07-15 15:52 ` tromey at sourceware dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at sourceware dot org @ 2021-07-15 15:44 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.1

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

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

* [Bug gdb/28093] set language unknown -> print "foo" -> GDB crash
  2021-07-15 13:41 [Bug gdb/28093] New: set language unknown -> print "foo" -> GDB crash pedro at palves dot net
                   ` (2 preceding siblings ...)
  2021-07-15 15:44 ` tromey at sourceware dot org
@ 2021-07-15 15:52 ` tromey at sourceware dot org
  2021-07-15 16:16 ` tromey at sourceware dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at sourceware dot org @ 2021-07-15 15:52 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
Not technically a regression, I suppose.
Fedora 32 /bin/gdb:

(gdb) print "hi"
../../gdb/parse.c:725: internal-error: int prefixify_expression(expression*,
int): Assertion `expr->nelts > 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) 


The default language "parser" just does:

  int parser (struct parser_state *ps) const override
  {
    /* No parsing is done, just claim success.  */
    return 1;
  }

... which is pretty lame / wrong.

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

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

* [Bug gdb/28093] set language unknown -> print "foo" -> GDB crash
  2021-07-15 13:41 [Bug gdb/28093] New: set language unknown -> print "foo" -> GDB crash pedro at palves dot net
                   ` (3 preceding siblings ...)
  2021-07-15 15:52 ` tromey at sourceware dot org
@ 2021-07-15 16:16 ` tromey at sourceware dot org
  2021-07-15 19:54 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at sourceware dot org @ 2021-07-15 16:16 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
https://sourceware.org/pipermail/gdb-patches/2021-July/180972.html

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

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

* [Bug gdb/28093] set language unknown -> print "foo" -> GDB crash
  2021-07-15 13:41 [Bug gdb/28093] New: set language unknown -> print "foo" -> GDB crash pedro at palves dot net
                   ` (4 preceding siblings ...)
  2021-07-15 16:16 ` tromey at sourceware dot org
@ 2021-07-15 19:54 ` cvs-commit at gcc dot gnu.org
  2021-07-19 17:08 ` cvs-commit at gcc dot gnu.org
  2021-07-19 17:09 ` tromey at sourceware dot org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-15 19:54 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #3 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom Tromey <tromey@sourceware.org>:

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

commit dcd482c1b756d9da2130552a6eb58b852d6efb97
Author: Tom Tromey <tromey@adacore.com>
Date:   Thu Jul 15 10:13:18 2021 -0600

    Avoid expression parsing crash with unknown language

    PR gdb/28093 points out that gdb crashes when language is set to
    "unknown" and expression parsing is attempted.  At first I thought
    this was a regression due to the expression rewrite, but it turns out
    that older versions crash as well.

    This patch avoids the crash by changing the default expression parser
    to throw an exception.  I think this is preferable -- the current
    behavior of silently doing nothing does not really make sense.

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

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

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

* [Bug gdb/28093] set language unknown -> print "foo" -> GDB crash
  2021-07-15 13:41 [Bug gdb/28093] New: set language unknown -> print "foo" -> GDB crash pedro at palves dot net
                   ` (5 preceding siblings ...)
  2021-07-15 19:54 ` cvs-commit at gcc dot gnu.org
@ 2021-07-19 17:08 ` cvs-commit at gcc dot gnu.org
  2021-07-19 17:09 ` tromey at sourceware dot org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-19 17:08 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #4 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The gdb-11-branch branch has been updated by Tom Tromey
<tromey@sourceware.org>:

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

commit e22715ce300957aabdf908a76fb1bf8bc17bba21
Author: Tom Tromey <tromey@adacore.com>
Date:   Thu Jul 15 10:13:18 2021 -0600

    Avoid expression parsing crash with unknown language

    PR gdb/28093 points out that gdb crashes when language is set to
    "unknown" and expression parsing is attempted.  At first I thought
    this was a regression due to the expression rewrite, but it turns out
    that older versions crash as well.

    This patch avoids the crash by changing the default expression parser
    to throw an exception.  I think this is preferable -- the current
    behavior of silently doing nothing does not really make sense.

    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28093
    (cherry picked from commit dcd482c1b756d9da2130552a6eb58b852d6efb97)

    gdb/ChangeLog
    2021-07-19  Tom Tromey  <tromey@adacore.com>

            PR gdb/28093
            * language.c (auto_or_unknown_language::parser): Call error.

    gdb/testsuite/ChangeLog
    2021-07-19  Tom Tromey  <tromey@adacore.com>

            PR gdb/28093
            * gdb.base/langs.exp: Add tests.

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

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

* [Bug gdb/28093] set language unknown -> print "foo" -> GDB crash
  2021-07-15 13:41 [Bug gdb/28093] New: set language unknown -> print "foo" -> GDB crash pedro at palves dot net
                   ` (6 preceding siblings ...)
  2021-07-19 17:08 ` cvs-commit at gcc dot gnu.org
@ 2021-07-19 17:09 ` tromey at sourceware dot org
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at sourceware dot org @ 2021-07-19 17:09 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

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

--- Comment #5 from Tom Tromey <tromey at sourceware dot org> ---
Fixed for gdb 11.

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

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

end of thread, other threads:[~2021-07-19 17:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-15 13:41 [Bug gdb/28093] New: set language unknown -> print "foo" -> GDB crash pedro at palves dot net
2021-07-15 13:43 ` [Bug gdb/28093] " pedro at palves dot net
2021-07-15 14:47 ` tromey at sourceware dot org
2021-07-15 15:44 ` tromey at sourceware dot org
2021-07-15 15:52 ` tromey at sourceware dot org
2021-07-15 16:16 ` tromey at sourceware dot org
2021-07-15 19:54 ` cvs-commit at gcc dot gnu.org
2021-07-19 17:08 ` cvs-commit at gcc dot gnu.org
2021-07-19 17:09 ` 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).