* [committed][gdb/symtab] Fix segfault in process_psymtab_comp_unit
@ 2021-05-27 13:27 Tom de Vries
2021-05-27 16:34 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2021-05-27 13:27 UTC (permalink / raw)
To: gdb-patches
Hi,
When running test-case gdb.dwarf2/dw2-dummy-cu.exp without -readnow, we run
into:
...
(gdb) file outputs/gdb.dwarf2/dw2-dummy-cu/dw2-dummy-cu^M
Reading symbols from outputs/gdb.dwarf2/dw2-dummy-cu/dw2-dummy-cu...^M
ERROR: Couldn't load dw2-dummy-cu into GDB (eof).
...
The problem is that we're running into a segfault:
...
Thread 1 "gdb" received signal SIGSEGV, Segmentation fault.
process_psymtab_comp_unit (this_cu=0x2141090, per_objfile=0x1aa4140,
want_partial_unit=false, pretend_language=language_minimal)
at /home/vries/gdb_versions/devel/src/gdb/dwarf2/read.c:7023
7023 switch (reader.comp_unit_die->tag)
...
due to reader.comp_unit_die == nullptr:
...
(gdb) p reader.comp_unit_die
$1 = (die_info *) 0x0
...
Indeed, there's no CU DIE in the test-case:
...
$ readelf -wi outputs/gdb.dwarf2/dw2-dummy-cu/dw2-dummy-cu
Contents of the .debug_info section:
Compilation Unit @ offset 0x0:
Length: 0x7 (32-bit)
Version: 2
Abbrev Offset: 0x0
Pointer Size: 4
$
...
Fix this by handling reader.comp_unit_die == nullptr in
process_psymtab_comp_unit.
Update the test-case to trigger this PR, as per PR27920 - "[gdb/testsuite]
hardcoding -readnow skips testing of partial symbols".
Tested on x86_64-linux.
Committed to trunk.
Thanks,
- Tom
[gdb/symtab] Fix segfault in process_psymtab_comp_unit
gdb/ChangeLog:
2021-05-27 Tom de Vries <tdevries@suse.de>
PR symtab/27919
* dwarf2/read.c (process_psymtab_comp_unit):
gdb/testsuite/ChangeLog:
2021-05-27 Tom de Vries <tdevries@suse.de>
PR symtab/27919
PR testsuite/27920
* gdb.dwarf2/dw2-dummy-cu.exp: Use maint expand-symtabs instead of
-readnow.
---
gdb/dwarf2/read.c | 3 +++
gdb/testsuite/gdb.dwarf2/dw2-dummy-cu.exp | 6 +-----
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 0da87bbecd6..4cc5b4f32d7 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -7020,6 +7020,9 @@ process_psymtab_comp_unit (dwarf2_per_cu_data *this_cu,
cutu_reader reader (this_cu, per_objfile, nullptr, nullptr, false);
+ if (reader.comp_unit_die == nullptr)
+ return;
+
switch (reader.comp_unit_die->tag)
{
case DW_TAG_compile_unit:
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-dummy-cu.exp b/gdb/testsuite/gdb.dwarf2/dw2-dummy-cu.exp
index 673972447a1..7871851e577 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-dummy-cu.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-dummy-cu.exp
@@ -27,13 +27,9 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != "
return -1
}
-set saved_gdbflags $GDBFLAGS
-set GDBFLAGS "$GDBFLAGS -readnow"
-
clean_restart $executable
+gdb_test_no_output "maint expand-symtab"
# Something simple to verify gdb didn't crash, and has read in whatever symbol
# info is there.
gdb_test "info fun main" "main_end"
-
-set GDBFLAGS $saved_gdbflags
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [committed][gdb/symtab] Fix segfault in process_psymtab_comp_unit
2021-05-27 13:27 [committed][gdb/symtab] Fix segfault in process_psymtab_comp_unit Tom de Vries
@ 2021-05-27 16:34 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2021-05-27 16:34 UTC (permalink / raw)
To: Tom de Vries; +Cc: gdb-patches
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
Tom> + if (reader.comp_unit_die == nullptr)
Tom> + return;
I think it's more normal to test the 'dummy_p' member.
There may be some other way in use as well though... probably this could
be cleaned up somehow.
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-05-27 16:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-27 13:27 [committed][gdb/symtab] Fix segfault in process_psymtab_comp_unit Tom de Vries
2021-05-27 16:34 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox