public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/30431] New: segfault when inspecting remote variable
@ 2023-05-08 21:05 marian.buschsieweke at ovgu dot de
  2023-05-09 15:01 ` [Bug gdb/30431] " tromey at sourceware dot org
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: marian.buschsieweke at ovgu dot de @ 2023-05-08 21:05 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 30431
           Summary: segfault when inspecting remote variable
           Product: gdb
           Version: 13.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: marian.buschsieweke at ovgu dot de
  Target Milestone: ---

When connecting to mspdebug to debug a microcontroller and printing the value
of the memory mapped register BCSCTL1 defined as:

msp430-gcc-support-files/include/msp430f2617_symbols.ld
98:PROVIDE(BCSCTL1            = 0x0057);

msp430-gcc-support-files/include/msp430f2617.h
414:sfr_b(BCSCTL1);                               /* Basic Clock System Control
1 */

/msp430-gcc-support-files/include/iomacros.h
62:#define sfr_b(x) extern volatile unsigned char x

with `p BCSCTL1` I get a segfault with the following backtrace:

#0  0x0000555555723324 in language_defn::read_var_value
(this=this@entry=0x555556d1e800 <c_language_defn>, 
    var=var@entry=0x7ffff6af8030, var_block=var_block@entry=0x7ffff6a6fbd0,
frame=...) at ../../gdb/findvar.c:756
#1  0x0000555555722326 in read_var_value (var=var@entry=0x7ffff6af8030,
var_block=var_block@entry=0x7ffff6a6fbd0, frame=...)
    at ../../gdb/findvar.c:794
#2  0x00005555559ab472 in value_of_variable (var=var@entry=0x7ffff6af8030,
b=0x7ffff6a6fbd0) at ../../gdb/valops.c:1385
#3  0x0000555555708151 in evaluate_var_value (noside=EVAL_NORMAL,
blk=<optimized out>, var=0x7ffff6af8030)
    at ../../gdb/eval.c:559
#4  0x000055555570a342 in expression::evaluate (this=0x7ffff6afad90,
expect_type=expect_type@entry=0x0, 
    noside=noside@entry=EVAL_NORMAL) at ../../gdb/eval.c:101
#5  0x000055555570a3b2 in evaluate_expression (exp=<optimized out>,
expect_type=expect_type@entry=0x0) at ../../gdb/eval.c:115
#6  0x0000555555848add in process_print_command_args (args=<optimized out>,
print_opts=print_opts@entry=0x7fffffffe00c, 
    voidprint=voidprint@entry=true) at
/usr/include/c++/12.2.1/bits/unique_ptr.h:191
#7  0x0000555555848eb5 in print_command_1 (args=<optimized out>, voidprint=1)
at ../../gdb/printcmd.c:1319
#8  0x0000555555670b63 in cmd_func (cmd=0x7ffff745ccd0, args=0x7ffff6a810d2
"BCSCTL1", from_tty=1)
    at ../../gdb/cli/cli-decode.c:2543
#9  0x000055555597c377 in execute_command (p=<optimized out>,
p@entry=0x7ffff6a810d0 "p BCSCTL1", from_tty=1)
    at ../../gdb/top.c:688
#10 0x000055555570c75e in command_handler (command=0x7ffff6a810d0 "p BCSCTL1")
at ../../gdb/event-top.c:616
#11 0x000055555570d4aa in command_line_handler (rl=...) at
../../gdb/event-top.c:852
#12 0x000055555570cf8c in gdb_rl_callback_handler (rl=0x7ffff6a810a0 "p
BCSCTL1") at ../../gdb/event-top.c:246
#13 0x00007ffff7ddf2d5 in rl_callback_read_char () from
/usr/lib/libreadline.so.8
#14 0x000055555570d042 in gdb_rl_callback_read_char_wrapper_noexcept () at
../../gdb/event-top.c:188
#15 0x000055555570d0e8 in gdb_rl_callback_read_char_wrapper
(client_data=<optimized out>) at ../../gdb/event-top.c:221
#16 0x000055555570c689 in stdin_event_handler (error=<optimized out>,
client_data=0x7ffff7f3cea0) at ../../gdb/event-top.c:541
#17 0x0000555555d60b0a in gdb_wait_for_event (block=<optimized out>) at
../../gdbsupport/event-loop.cc:716
#18 gdb_wait_for_event (block=<optimized out>) at
../../gdbsupport/event-loop.cc:585
#19 0x0000555555d612b7 in gdb_do_one_event (mstimeout=mstimeout@entry=-1) at
../../gdbsupport/event-loop.cc:264
#20 0x00005555557bed41 in start_event_loop () at ../../gdb/main.c:411
#21 captured_command_loop () at ../../gdb/main.c:471
#22 0x00005555557c0474 in captured_main (data=data@entry=0x7fffffffe460) at
../../gdb/main.c:1330
#23 gdb_main (args=args@entry=0x7fffffffe490) at ../../gdb/main.c:1345
#24 0x0000555555595ff6 in main (argc=<optimized out>, argv=<optimized out>) at
../../gdb/gdb.c:32

Specifically, the issue is in gdb/findvar.c at:

│      753          /* Relocate address, unless there is no section or the
variable is
│      754             a TLS variable. */
│      755          if (obj_section == NULL
│  >   756              || (obj_section->the_bfd_section->flags &
SEC_THREAD_LOCAL) != 0)
│      757             addr = bmsym.minsym->value_raw_address ();
│      758          else
│      759             addr = bmsym.value_address ();

(gdb) p *obj_section
$7 = {the_bfd_section = 0x0, objfile = 0x0, ovly_mapped = 0}

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

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

* [Bug gdb/30431] segfault when inspecting remote variable
  2023-05-08 21:05 [Bug gdb/30431] New: segfault when inspecting remote variable marian.buschsieweke at ovgu dot de
@ 2023-05-09 15:01 ` tromey at sourceware dot org
  2023-05-09 15:59 ` marian.buschsieweke at ovgu dot de
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: tromey at sourceware dot org @ 2023-05-09 15:01 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

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

--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
If the executable isn't too large, you could attach it.
That might provide enough info.

Otherwise, one question I have is what the symbol itself
looks like.  Like "print *bmsym.minsym".

Also this code seems to acknowledge that obj_section could
be null, but not that its contents could be.  So I wonder
if this:

        obj_section = bmsym.minsym->obj_section (bmsym.objfile);

call should be returning null instead.

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

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

* [Bug gdb/30431] segfault when inspecting remote variable
  2023-05-08 21:05 [Bug gdb/30431] New: segfault when inspecting remote variable marian.buschsieweke at ovgu dot de
  2023-05-09 15:01 ` [Bug gdb/30431] " tromey at sourceware dot org
@ 2023-05-09 15:59 ` marian.buschsieweke at ovgu dot de
  2023-05-09 16:53 ` marian.buschsieweke at ovgu dot de
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: marian.buschsieweke at ovgu dot de @ 2023-05-09 15:59 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #2 from Marian Buschsieweke <marian.buschsieweke at ovgu dot de> ---
Created attachment 14870
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14870&action=edit
hello-world.elf ; a broken firmware for the MSP430F1611 that I fail to debug

Thanks for the quick reply. I attached the binary in question, a simple
application that flashes on an MSP430F1611 MCU and outputs "Hello world" via
UART using RIOT. (Specifically,
https://github.com/maribu/RIOT/tree/tmp/examples/hello-world is the
corresponding code and can be generated by `make BOARD=olimex-msp430h1611`.)

Note that this firmware isn't functional; I'm in the process of figuring out
why the firmware generated with my new toolchain doesn't work, while it does
work with an older toolchain.

Here is the requested info:

(gdb) p *bmsym.minsym
$2 = {<general_symbol_info> = {m_name = 0x7ffff6ebed34 "BCSCTL1", m_value =
{ivalue = 87, block = 0x57, 
      bytes = 0x57 <error: Cannot access memory at address 0x57>, address = 87,
common_block = 0x57, chain = 0x57}, 
    language_specific = {obstack = 0x0, demangled_name = 0x0}, m_language =
language_auto, ada_mangled = 0, m_section = 0}, 
  m_size = 0, filename = 0x7ffff6bbb500 "irq.c", m_type = mst_abs,
created_by_gdb = 0, m_target_flag_1 = 0, 
  m_target_flag_2 = 0, m_has_size = 1, maybe_copied = 0, name_set = 1,
hash_next = 0x0, demangled_hash_next = 0x0}

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

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

* [Bug gdb/30431] segfault when inspecting remote variable
  2023-05-08 21:05 [Bug gdb/30431] New: segfault when inspecting remote variable marian.buschsieweke at ovgu dot de
  2023-05-09 15:01 ` [Bug gdb/30431] " tromey at sourceware dot org
  2023-05-09 15:59 ` marian.buschsieweke at ovgu dot de
@ 2023-05-09 16:53 ` marian.buschsieweke at ovgu dot de
  2023-06-02  7:19 ` marian.buschsieweke at posteo dot net
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: marian.buschsieweke at ovgu dot de @ 2023-05-09 16:53 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #3 from Marian Buschsieweke <marian.buschsieweke at ovgu dot de> ---
btw, the obvious "fix" seems to work here:

--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -752,15 +752,15 @@
        obj_section = bmsym.minsym->obj_section (bmsym.objfile);
        /* Relocate address, unless there is no section or the variable is
          a TLS variable. */
-       if (obj_section == NULL
-          || (obj_section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0)
+       if (obj_section == NULL ||
+          (obj_section->the_bfd_section &&
(obj_section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0))
          addr = bmsym.minsym->value_raw_address ();
        else
          addr = bmsym.value_address ();
        if (overlay_debugging)
         addr = symbol_overlayed_address (addr, obj_section);
        /* Determine address of TLS variable. */
-       if (obj_section
+       if (obj_section && obj_section->the_bfd_section
           && (obj_section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0)
         addr = target_translate_tls_address (obj_section->objfile, addr);
       }

I'm not sure if obj_section->the_bfd_section being NULL was just forgotten to
be taken into account, or if this is rather a symptom of some deeper issue.

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

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

* [Bug gdb/30431] segfault when inspecting remote variable
  2023-05-08 21:05 [Bug gdb/30431] New: segfault when inspecting remote variable marian.buschsieweke at ovgu dot de
                   ` (2 preceding siblings ...)
  2023-05-09 16:53 ` marian.buschsieweke at ovgu dot de
@ 2023-06-02  7:19 ` marian.buschsieweke at posteo dot net
  2023-06-02 15:06 ` tromey at sourceware dot org
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: marian.buschsieweke at posteo dot net @ 2023-06-02  7:19 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #4 from Marian Buschsieweke <marian.buschsieweke at posteo dot net> ---
Sorry to nag again.

Would the obvious fix (see patch in my previous message) be a sensible
solution? With it, I was able to do extensive debugging on my MSP430 board
without any regression experienced.

Thx for your effort! :)

PS: I could also provide a working ELF firmware now. But then again, without
the remote target and a JTAG debugger at hands it would be of little help to
reproduce the segfault.

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

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

* [Bug gdb/30431] segfault when inspecting remote variable
  2023-05-08 21:05 [Bug gdb/30431] New: segfault when inspecting remote variable marian.buschsieweke at ovgu dot de
                   ` (3 preceding siblings ...)
  2023-06-02  7:19 ` marian.buschsieweke at posteo dot net
@ 2023-06-02 15:06 ` tromey at sourceware dot org
  2023-06-03 18:28 ` marian.buschsieweke at posteo dot net
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: tromey at sourceware dot org @ 2023-06-02 15:06 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #5 from Tom Tromey <tromey at sourceware dot org> ---
Sorry about the delay on this.

I think it would be better to understand the problem a little more.
The main concern here is that there might be other spots that
would be affected, depending on the command you run; but if the
problem occurs when reading symbols and is fixed there, then that
might fix all instances of the bug.

When I run gdb on the ELF you provided, I don't see the crash.
But maybe it only occurs when connected to the target.

For me gdb thinks the symbol is in:

(top-gdb) p *obj_section.the_bfd_section
$8 = {
  name = 0x291928b "__interrupt_vector_4",


Maybe one way to reproduce the bug without me needing a working
system is a remote log.  If you can do something like:

$ gdb -nx
(gdb) set remotelogfile /tmp/whatever
(gdb) target remote ...
(gdb) break / continue / whatever to reproduce the bug
(gdb) print BCSCTL1

... then send the log.  This can be replayed here without needing
anything else.  (Though if you have to pass a file when starting
gdb, or use "file" or something like that, then the exact files
used would also be needed.)

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

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

* [Bug gdb/30431] segfault when inspecting remote variable
  2023-05-08 21:05 [Bug gdb/30431] New: segfault when inspecting remote variable marian.buschsieweke at ovgu dot de
                   ` (4 preceding siblings ...)
  2023-06-02 15:06 ` tromey at sourceware dot org
@ 2023-06-03 18:28 ` marian.buschsieweke at posteo dot net
  2023-06-03 18:29 ` marian.buschsieweke at posteo dot net
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: marian.buschsieweke at posteo dot net @ 2023-06-03 18:28 UTC (permalink / raw)
  To: gdb-prs

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

Marian Buschsieweke <marian.buschsieweke at posteo dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #14870|0                           |1
        is obsolete|                            |

--- Comment #6 from Marian Buschsieweke <marian.buschsieweke at posteo dot net> ---
Created attachment 14914
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14914&action=edit
hello-world.elf (new version)

Thx for your reply and sorry for the long latency. I can still reproduce the
issue; using a new ELF file this time (see attachment).

    $ gdb gdb-multiarch
    [...]
    (gdb) run -nx bin/olimex-msp430-h1611/hello-world.elf 
    [...]
    For help, type "help".
    Type "apropos word" to search for commands related to "word"...
    Reading symbols from bin/olimex-msp430-h1611/hello-world.elf...
    (gdb) set remotelogfile /home/maribu/remotelogfile
    (gdb) tar rem :2000
    Remote debugging using :2000
    __crt0_start () at
/home/buildozer/aports/community/newlib/src/newlib-4.3.0.20230120/libgloss/msp430/crt0.S:56
    56 
/home/buildozer/aports/community/newlib/src/newlib-4.3.0.20230120/libgloss/msp430/crt0.S:
No such file or directory.
    (gdb) p BCSCTL1 

    Thread 1 "gdb-multiarch" received signal SIGSEGV, Segmentation fault.
    0x000055555586ae9a in language_defn::read_var_value (this=<optimized out>,
var=0x7ffff6acaec0, var_block=0x7ffff6a36b70, frame=...) at
../../gdb/findvar.c:756
    756 ../../gdb/findvar.c: No such file or directory.
    (gdb) bt
    #0  0x000055555586ae9a in language_defn::read_var_value (this=<optimized
out>, var=0x7ffff6acaec0, var_block=0x7ffff6a36b70, frame=...) at
../../gdb/findvar.c:756
    #1  0x0000555555867c1f in read_var_value (var=var@entry=0x7ffff6acaec0,
var_block=var_block@entry=0x7ffff6a36b70, frame=...) at ../../gdb/findvar.c:794
    #2  0x0000555555cbf5e8 in value_of_variable (var=var@entry=0x7ffff6acaec0,
b=0x7ffff6a36b70) at ../../gdb/valops.c:1385
    #3  0x000055555583e2db in evaluate_var_value (var=0x7ffff6acaec0,
blk=<optimized out>, noside=EVAL_NORMAL) at ../../gdb/eval.c:559
    #4  expr::var_value_operation::evaluate (this=0x7ffff6a9ee70,
expect_type=<optimized out>, exp=<optimized out>, noside=EVAL_NORMAL) at
../../gdb/eval.c:585
    #5  0x000055555583e37d in expression::evaluate (this=0x7ffff6a9edd0,
expect_type=0x0, noside=noside@entry=EVAL_NORMAL) at ../../gdb/eval.c:101
    #6  0x000055555583e6f7 in evaluate_expression (exp=<optimized out>,
expect_type=<optimized out>) at ../../gdb/eval.c:115
    #7  0x0000555555a84d91 in process_print_command_args (args=<optimized out>,
print_opts=print_opts@entry=0x7fffffffdfa0, voidprint=voidprint@entry=true)
        at /usr/include/c++/13.1.1/bits/unique_ptr.h:199
    #8  0x0000555555a85d80 in print_command_1 (args=<optimized out>,
voidprint=1) at ../../gdb/printcmd.c:1319
    #9  0x0000555555732f9d in cmd_func (cmd=<optimized out>, args=<optimized
out>, from_tty=<optimized out>) at ../../gdb/cli/cli-decode.c:2543
    #10 0x0000555555c6fbb0 in execute_command (p=<optimized out>,
p@entry=0x7ffff70abac0 "p BCSCTL1 ", from_tty=<optimized out>) at
../../gdb/top.c:690
    #11 0x00005555558454cd in command_handler (command=0x7ffff70abac0 "p
BCSCTL1 ") at ../../gdb/event-top.c:616
    #12 0x0000555555846ddd in command_line_handler (rl=...) at
../../gdb/event-top.c:852
    #13 0x0000555555845a24 in gdb_rl_callback_handler (rl=0x7ffff70aba90 "p
BCSCTL1 ") at ../../gdb/event-top.c:246
    #14 0x00007ffff7ddfc86 in rl_callback_read_char () from
/usr/lib/libreadline.so.8
    #15 0x0000555555845b6e in gdb_rl_callback_read_char_wrapper_noexcept () at
../../gdb/event-top.c:188
    #16 0x0000555555845ce0 in gdb_rl_callback_read_char_wrapper
(client_data=<optimized out>) at ../../gdb/event-top.c:221
    #17 0x0000555555844bf8 in stdin_event_handler (error=<optimized out>,
client_data=0x7ffff7f04e70) at ../../gdb/event-top.c:541
    #18 0x00005555561a5f6c in gdb_wait_for_event (block=block@entry=1) at
../../gdbsupport/event-loop.cc:716
    #19 0x00005555561a68f0 in gdb_wait_for_event (block=1) at
../../gdbsupport/event-loop.cc:593
    #20 gdb_do_one_event (mstimeout=mstimeout@entry=-1) at
../../gdbsupport/event-loop.cc:264
    #21 0x000055555599fb6a in start_event_loop () at ../../gdb/main.c:411
    #22 captured_command_loop () at ../../gdb/main.c:471
    #23 0x00005555559a1ac5 in captured_main (data=data@entry=0x7fffffffe420) at
../../gdb/main.c:1330
    #24 gdb_main (args=args@entry=0x7fffffffe450) at ../../gdb/main.c:1345
    #25 0x00005555555d4e6a in main (argc=<optimized out>, argv=<optimized out>)
at ../../gdb/gdb.c:32

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

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

* [Bug gdb/30431] segfault when inspecting remote variable
  2023-05-08 21:05 [Bug gdb/30431] New: segfault when inspecting remote variable marian.buschsieweke at ovgu dot de
                   ` (5 preceding siblings ...)
  2023-06-03 18:28 ` marian.buschsieweke at posteo dot net
@ 2023-06-03 18:29 ` marian.buschsieweke at posteo dot net
  2023-06-03 20:31 ` tromey at sourceware dot org
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: marian.buschsieweke at posteo dot net @ 2023-06-03 18:29 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #7 from Marian Buschsieweke <marian.buschsieweke at posteo dot net> ---
Created attachment 14915
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14915&action=edit
remotelogfile stored during above crash

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

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

* [Bug gdb/30431] segfault when inspecting remote variable
  2023-05-08 21:05 [Bug gdb/30431] New: segfault when inspecting remote variable marian.buschsieweke at ovgu dot de
                   ` (6 preceding siblings ...)
  2023-06-03 18:29 ` marian.buschsieweke at posteo dot net
@ 2023-06-03 20:31 ` tromey at sourceware dot org
  2023-06-03 21:33 ` marian.buschsieweke at posteo dot net
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: tromey at sourceware dot org @ 2023-06-03 20:31 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #8 from Tom Tromey <tromey at sourceware dot org> ---
My gdb isn't sending exactly the same remote protocol traffic as yours;
I wonder if we're running different versions or if I need to configure
differently.  Could you send the output of:

$ gdb --version
$ gdb --config

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

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

* [Bug gdb/30431] segfault when inspecting remote variable
  2023-05-08 21:05 [Bug gdb/30431] New: segfault when inspecting remote variable marian.buschsieweke at ovgu dot de
                   ` (7 preceding siblings ...)
  2023-06-03 20:31 ` tromey at sourceware dot org
@ 2023-06-03 21:33 ` marian.buschsieweke at posteo dot net
  2023-06-03 21:35 ` marian.buschsieweke at posteo dot net
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: marian.buschsieweke at posteo dot net @ 2023-06-03 21:33 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #9 from Marian Buschsieweke <marian.buschsieweke at posteo dot net> ---
> My gdb isn't sending exactly the same remote protocol traffic as yours;

Sorry, this my fault. When I reported the bug I was using version 13.1, but in
the meantime Alpine updated to version 13.2. The remotelogfile was captured
with version 13.2.

$ gdb --version            
GNU gdb (GDB) 13.2
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.
$ gdb --config 
This GDB was configured as follows:
   configure --host=x86_64-alpine-linux-musl --target=x86_64-alpine-linux-musl
            --with-auto-load-dir=$debugdir:$datadir/auto-load
            --with-auto-load-safe-path=$debugdir:$datadir/auto-load
            --with-expat
            --with-gdb-datadir=/usr/share/gdb (relocatable)
            --with-jit-reader-dir=/usr/lib/gdb (relocatable)
            --without-libunwind-ia64
            --without-lzma
            --without-babeltrace
            --without-intel-pt
            --without-mpfr
            --without-xxhash
            --with-python=/usr (relocatable)
            --with-python-libdir=/usr/lib (relocatable)
            --without-debuginfod
            --without-guile
            --disable-source-highlight
            --enable-threading
            --with-separate-debug-dir=/usr/lib/debug (relocatable)

("Relocatable" means the directory can be moved with the GDB installation
tree, and GDB will still find it.)

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

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

* [Bug gdb/30431] segfault when inspecting remote variable
  2023-05-08 21:05 [Bug gdb/30431] New: segfault when inspecting remote variable marian.buschsieweke at ovgu dot de
                   ` (8 preceding siblings ...)
  2023-06-03 21:33 ` marian.buschsieweke at posteo dot net
@ 2023-06-03 21:35 ` marian.buschsieweke at posteo dot net
  2023-06-04 17:25 ` tromey at sourceware dot org
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: marian.buschsieweke at posteo dot net @ 2023-06-03 21:35 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #10 from Marian Buschsieweke <marian.buschsieweke at posteo dot net> ---
Sorry again. Wrong binaries :/ Now with the correct GDB:

$ gdb-multiarch --version  
GNU gdb (GDB) 13.2
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.
$ gdb-multiarch --config 
This GDB was configured as follows:
   configure --host=x86_64-alpine-linux-musl --target=x86_64-alpine-linux-musl
            --with-auto-load-dir=$debugdir:$datadir/auto-load
            --with-auto-load-safe-path=$debugdir:$datadir/auto-load
            --with-expat
            --with-gdb-datadir=/usr/share/gdb (relocatable)
            --with-jit-reader-dir=/usr/lib/gdb (relocatable)
            --without-libunwind-ia64
            --without-lzma
            --without-babeltrace
            --without-intel-pt
            --without-mpfr
            --without-xxhash
            --with-python=/usr (relocatable)
            --with-python-libdir=/usr/lib (relocatable)
            --without-debuginfod
            --without-guile
            --disable-source-highlight
            --enable-threading
            --with-separate-debug-dir=/usr/lib/debug (relocatable)

("Relocatable" means the directory can be moved with the GDB installation
tree, and GDB will still find it.)

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

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

* [Bug gdb/30431] segfault when inspecting remote variable
  2023-05-08 21:05 [Bug gdb/30431] New: segfault when inspecting remote variable marian.buschsieweke at ovgu dot de
                   ` (9 preceding siblings ...)
  2023-06-03 21:35 ` marian.buschsieweke at posteo dot net
@ 2023-06-04 17:25 ` tromey at sourceware dot org
  2023-06-04 20:19 ` marian.buschsieweke at posteo dot net
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: tromey at sourceware dot org @ 2023-06-04 17:25 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #11 from Tom Tromey <tromey at sourceware dot org> ---
Thanks, I have it working now.

I found some suspicious code in elfread.c.
I'm not sure of a fully correct fix but I wonder if you could try this:

diff --git a/gdb/elfread.c b/gdb/elfread.c
index ceaf81f0fca..9998801b8dd 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -210,7 +210,8 @@ record_minimal_symbol (minimal_symbol_reader &reader,
      ELF is malformed then this might not be the case.  In that case don't
      create an msymbol that references an uninitialised section object.  */
   int section_index = 0;
-  if ((bfd_section_flags (bfd_section) & SEC_ALLOC) == SEC_ALLOC)
+  if ((bfd_section_flags (bfd_section) & SEC_ALLOC) == SEC_ALLOC
+      || bfd_section == bfd_abs_section_ptr)
     section_index = gdb_bfd_section_index (objfile->obfd.get (), bfd_section);

   struct minimal_symbol *result

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

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

* [Bug gdb/30431] segfault when inspecting remote variable
  2023-05-08 21:05 [Bug gdb/30431] New: segfault when inspecting remote variable marian.buschsieweke at ovgu dot de
                   ` (10 preceding siblings ...)
  2023-06-04 17:25 ` tromey at sourceware dot org
@ 2023-06-04 20:19 ` marian.buschsieweke at posteo dot net
  2023-06-20 21:20 ` tromey at sourceware dot org
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: marian.buschsieweke at posteo dot net @ 2023-06-04 20:19 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #12 from Marian Buschsieweke <marian.buschsieweke at posteo dot net> ---
(In reply to Tom Tromey from comment #11)
> I found some suspicious code in elfread.c.
> I'm not sure of a fully correct fix but I wonder if you could try this:

This indeed solves the issue for me, thx :)

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

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

* [Bug gdb/30431] segfault when inspecting remote variable
  2023-05-08 21:05 [Bug gdb/30431] New: segfault when inspecting remote variable marian.buschsieweke at ovgu dot de
                   ` (11 preceding siblings ...)
  2023-06-04 20:19 ` marian.buschsieweke at posteo dot net
@ 2023-06-20 21:20 ` tromey at sourceware dot org
  2023-06-20 21:21 ` tromey at sourceware dot org
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: tromey at sourceware dot org @ 2023-06-20 21:20 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-06-20
             Status|UNCONFIRMED                 |NEW
           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] 17+ messages in thread

* [Bug gdb/30431] segfault when inspecting remote variable
  2023-05-08 21:05 [Bug gdb/30431] New: segfault when inspecting remote variable marian.buschsieweke at ovgu dot de
                   ` (12 preceding siblings ...)
  2023-06-20 21:20 ` tromey at sourceware dot org
@ 2023-06-20 21:21 ` tromey at sourceware dot org
  2023-07-10 17:19 ` cvs-commit at gcc dot gnu.org
  2023-07-10 17:19 ` tromey at sourceware dot org
  15 siblings, 0 replies; 17+ messages in thread
From: tromey at sourceware dot org @ 2023-06-20 21:21 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #13 from Tom Tromey <tromey at sourceware dot org> ---
https://sourceware.org/pipermail/gdb-patches/2023-June/200406.html

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

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

* [Bug gdb/30431] segfault when inspecting remote variable
  2023-05-08 21:05 [Bug gdb/30431] New: segfault when inspecting remote variable marian.buschsieweke at ovgu dot de
                   ` (13 preceding siblings ...)
  2023-06-20 21:21 ` tromey at sourceware dot org
@ 2023-07-10 17:19 ` cvs-commit at gcc dot gnu.org
  2023-07-10 17:19 ` tromey at sourceware dot org
  15 siblings, 0 replies; 17+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-10 17:19 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #14 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=dd2532ad8af1676450114e4884ad748d528eafbe

commit dd2532ad8af1676450114e4884ad748d528eafbe
Author: Tom Tromey <tom@tromey.com>
Date:   Tue Jun 20 15:18:23 2023 -0600

    Avoid crash with absolute symbol

    A user supplied an executable and a remote logfile that could be used
    to crash gdb.  The problem is that the BFD section for a particular
    symbol was null, because the section was not marked "allocated".
    Digging deeper, the problem was that elfread.c dropped the section for
    absolute symbols.  This patch fixes the crash.

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

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

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

* [Bug gdb/30431] segfault when inspecting remote variable
  2023-05-08 21:05 [Bug gdb/30431] New: segfault when inspecting remote variable marian.buschsieweke at ovgu dot de
                   ` (14 preceding siblings ...)
  2023-07-10 17:19 ` cvs-commit at gcc dot gnu.org
@ 2023-07-10 17:19 ` tromey at sourceware dot org
  15 siblings, 0 replies; 17+ messages in thread
From: tromey at sourceware dot org @ 2023-07-10 17:19 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |14.1
         Resolution|---                         |FIXED

--- Comment #15 from Tom Tromey <tromey at sourceware dot org> ---
Fixed.

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

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

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

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-08 21:05 [Bug gdb/30431] New: segfault when inspecting remote variable marian.buschsieweke at ovgu dot de
2023-05-09 15:01 ` [Bug gdb/30431] " tromey at sourceware dot org
2023-05-09 15:59 ` marian.buschsieweke at ovgu dot de
2023-05-09 16:53 ` marian.buschsieweke at ovgu dot de
2023-06-02  7:19 ` marian.buschsieweke at posteo dot net
2023-06-02 15:06 ` tromey at sourceware dot org
2023-06-03 18:28 ` marian.buschsieweke at posteo dot net
2023-06-03 18:29 ` marian.buschsieweke at posteo dot net
2023-06-03 20:31 ` tromey at sourceware dot org
2023-06-03 21:33 ` marian.buschsieweke at posteo dot net
2023-06-03 21:35 ` marian.buschsieweke at posteo dot net
2023-06-04 17:25 ` tromey at sourceware dot org
2023-06-04 20:19 ` marian.buschsieweke at posteo dot net
2023-06-20 21:20 ` tromey at sourceware dot org
2023-06-20 21:21 ` tromey at sourceware dot org
2023-07-10 17:19 ` cvs-commit at gcc dot gnu.org
2023-07-10 17:19 ` 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).