Bug 29323 - [gdb/symtab] read.c:3963: internal-error: dw2_expand_symtabs_matching_one: Assertion `symtab != nullptr' failed.
Summary: [gdb/symtab] read.c:3963: internal-error: dw2_expand_symtabs_matching_one: As...
Status: RESOLVED DUPLICATE of bug 29334
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-06 14:28 UTC by Tom de Vries
Modified: 2022-07-12 12:22 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Vries 2022-07-06 14:28:32 UTC
With test-case gdb.dwarf2/struct-with-sig.exp and target board cc-with-debug-names I run into:
...
(gdb) ptype struct s^M
/home/vries/gdb_versions/devel/src/gdb/dwarf2/read.c:3963: internal-error: dw2_expand_symtabs_matching_one: Assertion `symtab != nullptr' failed.^M
A problem internal to GDB has been detected,^M
further debugging may prove unreliable.^M
----- Backtrace -----^M
FAIL: gdb.dwarf2/struct-with-sig.exp: struct s with int i (GDB internal error)
...

This is easily enough fixed by:
...
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 017cde0dcd9..97be0aaa0db 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -3960,9 +3960,8 @@ dw2_expand_symtabs_matching_one
 
       compunit_symtab *symtab
        = dw2_instantiate_symtab (per_cu, per_objfile, false);
-      gdb_assert (symtab != nullptr);
 
-      if (expansion_notify != NULL && symtab_was_null)
+      if (symtab != nullptr && expansion_notify != NULL && symtab_was_null)

        return expansion_notify (symtab);
     }
   return true;
...

Still, we're trying to print struct s, in the context of main, which has a struct s decl with sig reference to a struct s in a TU.

So why are we're trying to instantiate the dummy CU at offset 0x9a:
...
  Compilation Unit @ offset 0x8f:
   Length:        0x7 (32-bit)
   Version:       4
   Abbrev Offset: 0x59
   Pointer Size:  8
  Compilation Unit @ offset 0x9a:
...
which contains no symbols and is indeed not listed as containing any symbols in the .debug_names index?

Is this because the index is missing information?  That is, it has:
...
[ 15] #0002b618 s:
        <5> DW_TAG_structure_type DW_IDX_type_unit=0 DW_IDX_GNU_internal=1
        <5> DW_TAG_structure_type DW_IDX_type_unit=1 DW_IDX_GNU_internal=1
...
but there's no indication that the foo and main compilation units also contain those types (using aforementioned decl-with-sig-ref).
Comment 1 Tom de Vries 2022-07-08 07:39:32 UTC
No longer fails with the tentative fix for PR29334, so probably a duplicate.
Comment 2 Tom de Vries 2022-07-12 12:22:14 UTC
No longer fails on master, marking as duplicate.

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