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

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