Bug 24865 - gdb crashes while debugging due to invalid pointer exception in value.c:416.
Summary: gdb crashes while debugging due to invalid pointer exception in value.c:416.
Status: RESOLVED DUPLICATE of bug 20020
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 8.2
: P2 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-31 04:02 UTC by Cristiano
Modified: 2020-04-08 12:16 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2020-03-24 00:00:00
Project(s) to access:
ssh public key:


Attachments
Test case for Segfault in value_entirely_covered_by_range_vector (454 bytes, text/x-c++src)
2020-01-02 14:49 UTC, Joseph Schuchart
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Cristiano 2019-07-31 04:02:20 UTC
I ran gdb --args gdb ./binary and can now share this:

Program received signal SIGSEGV, Segmentation fault.
0x00005555558fdfdc in value_entirely_covered_by_range_vector (value=value@entry=0x0, ranges=...) at value.c:416
416	  if (value->lazy)


I've encountered the bug in I think 8.1 but the problem persists until the very last version which I also tried (the gdb output is from debugging the 8.3). I've been struggling to make do while debugging my projects because gdb will unpredictably crash so often on my machine it is in fact unusable to me and I have to resort to painstakingly adding cout<<'s and recompiling.
Comment 1 Joseph Schuchart 2020-01-02 14:49:41 UTC
Created attachment 12162 [details]
Test case for Segfault in value_entirely_covered_by_range_vector

Build:

```
$ g++ -std=c++17 -g test_gdb_optout.cc -o test_gdb_optout
```

Run:

```
$ gdb -ex "b main" -ex r test_gdb_optout
GNU gdb (GDB) 8.3
[...]
Breakpoint 1, main () at test_gdb_optout.cc:69
69	{
(gdb) n
70	  X1T<long, int> X{new long[10], 10};
(gdb) 
71	  foo(X);
(gdb) print X
Segmentation fault (core dumped)

```
Comment 2 Joseph Schuchart 2020-01-02 19:25:17 UTC
Here is the stack trace I get when running the test case inside a second gdb instance:

(gdb) print X

Program received signal SIGSEGV, Segmentation fault.
value_entirely_covered_by_range_vector (value=value@entry=0x0, ranges=...) at ../../gdb/value.c:416
416	  if (value->lazy)
(gdb) bt
#0  value_entirely_covered_by_range_vector (value=value@entry=0x0, ranges=...) at ../../gdb/value.c:416
#1  0x00005555558ffa2c in value_entirely_optimized_out (value=value@entry=0x0) at ../../gdb/value.c:441
#2  0x00005555556cb5c7 in cp_print_static_field (options=0x7fffffffd6e0, recurse=1, stream=0x555555facb40, val=0x0, type=0x55555608e1b0) at ../../gdb/cp-valprint.c:630
#3  cp_print_value_fields (type=<optimized out>, real_type=real_type@entry=0x5555561080e0, offset=offset@entry=0, address=address@entry=140737488346512, 
    stream=0x555555facb40, recurse=0, val=0x555556254060, options=0x7fffffffd6e0, dont_print_vb=0x0, dont_print_statmem=0) at ../../gdb/cp-valprint.c:332
#4  0x00005555556cbf2d in cp_print_value_fields_rtti (type=<optimized out>, type@entry=0x5555561080e0, valaddr=valaddr@entry=0x5555563321c0 "", offset=offset@entry=0, 
    address=140737488346512, stream=0x555555facb40, recurse=<optimized out>, val=0x555556254060, options=0x7fffffffd6e0, dont_print_vb=0x0, dont_print_statmem=0)
    at ../../gdb/cp-valprint.c:449
#5  0x000055555567e681 in c_val_print_struct (type=0x5555561080e0, valaddr=0x5555563321c0 "", embedded_offset=0, address=<optimized out>, stream=<optimized out>, 
    recurse=<optimized out>, original_value=0x555556254060, options=0x7fffffffd6e0) at ../../gdb/c-valprint.c:411
#6  0x000055555567eb80 in c_val_print (type=<optimized out>, embedded_offset=0, address=140737488346512, stream=0x555555facb40, recurse=0, original_value=0x555556254060, 
    options=0x7fffffffd6e0) at ../../gdb/c-valprint.c:532
#7  0x00005555558f78c4 in val_print (type=type@entry=0x555556109b10, embedded_offset=0, address=address@entry=140737488346512, stream=stream@entry=0x555555facb40, 
    recurse=recurse@entry=0, val=val@entry=0x555556254060, options=<optimized out>, language=0x555555eaa0a0 <cplus_language_defn>) at ../../gdb/valprint.c:1061
#8  0x000055555567f314 in c_value_print (val=0x555556254060, stream=0x555555facb40, options=<optimized out>) at ../../gdb/c-valprint.c:701
#9  0x00005555558159ad in print_value (val=val@entry=0x555556254060, fmtp=fmtp@entry=0x7fffffffd8d0) at ../../gdb/printcmd.c:1166
#10 0x0000555555815a65 in print_command_1 (exp=<optimized out>, voidprint=1) at ../../gdb/printcmd.c:1194
#11 0x000055555568aea2 in cmd_func (cmd=<optimized out>, args=<optimized out>, from_tty=<optimized out>) at ../../gdb/cli/cli-decode.c:1892
#12 0x00005555558cfe25 in execute_command (p=<optimized out>, p@entry=0x555555f0f8d0 "print X", from_tty=1) at ../../gdb/top.c:630
#13 0x0000555555736bdc in command_handler (command=0x555555f0f8d0 "print X") at ../../gdb/event-top.c:583
#14 0x0000555555736fad in command_line_handler (rl=...) at ../../gdb/event-top.c:770
#15 0x0000555555735c81 in gdb_rl_callback_handler (rl=0x555556253a50 "print X") at ../../gdb/event-top.c:213
#16 0x000055555591d51f in rl_callback_read_char () at ../../readline/callback.c:220
#17 0x0000555555735b96 in gdb_rl_callback_read_char_wrapper_noexcept () at ../../gdb/event-top.c:175
#18 0x0000555555735c19 in gdb_rl_callback_read_char_wrapper (client_data=<optimized out>) at ../../gdb/event-top.c:192
#19 0x0000555555736220 in stdin_event_handler (error=<optimized out>, client_data=0x555555f07870) at ../../gdb/event-top.c:511
#20 0x0000555555734ecd in gdb_wait_for_event (block=block@entry=1) at ../../gdb/event-loop.c:859
#21 0x0000555555735042 in gdb_do_one_event () at ../../gdb/event-loop.c:347
#22 0x00005555557351be in gdb_do_one_event () at ../../gdb/event-loop.c:304
#23 start_event_loop () at ../../gdb/event-loop.c:371
#24 0x00005555557d03e8 in captured_command_loop () at ../../gdb/main.c:331
#25 0x00005555557d15a5 in captured_main (data=<optimized out>) at ../../gdb/main.c:1182
#26 gdb_main (args=<optimized out>) at ../../gdb/main.c:1198
#27 0x00005555556006db in main (argc=<optimized out>, argv=<optimized out>) at ../../gdb/gdb.c:32
Comment 3 Tom Tromey 2020-03-24 16:05:05 UTC
With git master I get:

(gdb) p X
$1 = {static ndims = <error reading variable: Missing ELF symbol "X<long, 1, Y<1, int, 1> >::ndims".>, _a = {static ndims = <error reading variable: Missing ELF symbol "Y<1, int, 1>::ndims".>, 
    static bases = <error reading variable: Missing ELF symbol "Y<1, int, 1>::bases".>, _size = 0, _offsets = {_M_elems = {0}}}}


... which is at least not a crash.

This seems familiar, I think it's some known bug with C++17 DWARF?
I forget, we'll have to dig a little to find it.
Comment 4 Hannes Domani 2020-04-08 12:16:38 UTC
Dup.

*** This bug has been marked as a duplicate of bug 20020 ***