A user reported a gdb crash with gdb-11.1 ( https://bugzilla.opensuse.org/show_bug.cgi?id=1192285 ) and shared the reproducer with me. The reproducer is something like: ... $ gdb -q -batch exec core -ex bt ... I managed to reproduce with master. AFAIU, the following happens. psymbol_functions::expand_symtabs_matching is called and we arrive here: ... struct compunit_symtab *symtab = psymtab_to_symtab (objfile, ps); if (expansion_notify != NULL) if (!expansion_notify (symtab)) return false; ... with symtab == nullptr due to ps being a dwarf2_include_psymtab. The expansion_notify is lambda function search_one_symtab, as passed by objfile::lookup_symbol and the null pointer is dereferenced here: ... auto search_one_symtab = [&] (compunit_symtab *stab) { ... const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (stab); ...
I tried this patch: ... diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 48fb55c308c..9cd9ab4fbf1 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -5787,7 +5787,7 @@ struct dwarf2_include_psymtab : public partial_symtab compunit_symtab *get_compunit_symtab (struct objfile *objfile) const override { - return nullptr; + return includer ()->get_compunit_symtab (objfile); } private: ... and I was able to finish the backtrace.
https://sourceware.org/pipermail/gdb-patches/2021-November/183363.html
Reproduced with: - master - gdb-11-branch On 10.2, runs into PR26327.
Any news on this? I am repeatedly hitting it.
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=49fa1332a69bc4b09d2cc7db587e27ea30f2a29d