Bug 23270 - GDB internal error: dwarf2read.c:18656: internal-error: could not find partial DIE 0x1b7 in cache
Summary: GDB internal error: dwarf2read.c:18656: internal-error: could not find partia...
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: 10.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-06-08 13:44 UTC by Tom de Vries
Modified: 2020-08-04 09:18 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 2018-06-08 13:44:47 UTC
[ This might be a duplicate of PR16000 - Need better recovery from "could not find partial DIE 0x1234 in cache" ]

[ At fd161d860f1df7140153eab4726705cc3e2727b0 "Fri Jun 8 20:17:34 2018 +0930" "Define various symbols conditionally in shared librarie". ]

I see in the testsuite:
...
Running src/gdb/testsuite/gdb.arch/amd64-entry-value-paramref.exp ...
FAIL: gdb.arch/amd64-entry-value-paramref.exp: (build/gdb/testsuite/outputs/gdb.arch/amd64-entry-value-paramref/amd64-entry-value-paramref) (GDB internal error)
...

In more detail:
...
(gdb) file build/gdb/testsuite/outputs/gdb.arch/amd64-entry-value-paramref/amd64-entry-value-paramref^M
Reading symbols from build/gdb/testsuite/outputs/gdb.arch/amd64-entry-value-paramref/amd64-entry-value-paramref.../home/vries/gdb_versions/devel/src/gdb/dwarf2read.c:18656: internal-error: could not find partial DIE 0x1b7 in cache [from module build/gdb/testsuite/outputs/gdb.arch/amd64-entry-value-paramref/amd64-entry-value-paramref]^M
^M
A problem internal to GDB has been detected,^M
further debugging may prove unreliable.^M
Quit this debugging session? (y or n) FAIL: gdb.arch/amd64-entry-value-paramref.exp: (build/gdb/testsuite/outputs/gdb.arch/amd64-entry-value-paramref/amd64-entry-value-paramref) (GDB internal error)
Resyncing due to internal error.
...
Comment 1 Tom de Vries 2019-05-09 12:58:48 UTC
(In reply to Tom de Vries from comment #0)
> I see in the testsuite:
> ...
> Running src/gdb/testsuite/gdb.arch/amd64-entry-value-paramref.exp ...
> FAIL: gdb.arch/amd64-entry-value-paramref.exp:
> (build/gdb/testsuite/outputs/gdb.arch/amd64-entry-value-paramref/amd64-entry-
> value-paramref) (GDB internal error)
> ...

The test-case contained invalid dwarf and has been fixed, so in order to trigger this error the test-case fix needs to be reverted.
Comment 2 Tom Tromey 2020-07-23 14:10:55 UTC
> The test-case contained invalid dwarf and has been fixed, so in order to
> trigger this error the test-case fix needs to be reverted.

Since it was a buggy test, should we just close this PR now?
Comment 3 Christian Biesinger 2020-07-23 19:22:04 UTC
Invalid DWARF should maybe not lead to internal errors?
Comment 4 Tom Tromey 2020-07-23 20:17:37 UTC
(In reply to Christian Biesinger from comment #3)
> Invalid DWARF should maybe not lead to internal errors?

Yeah, that's true.
I guess it's fine to leave open.
If no compiler has ever emitted it, then I personally
feel like it's not super important.
Comment 5 Tom de Vries 2020-07-24 08:19:07 UTC
Still reproduces:(In reply to Christian Biesinger from comment #3)
> Invalid DWARF should maybe not lead to internal errors?

Right.  And in contrast, when using -readnow, we have no internal error:
...
$ gdb -readnow amd64-entry-value-paramref 
Reading symbols from amd64-entry-value-paramref...
Expanding full symbols from amd64-entry-value-paramref...
Dwarf Error: Cannot find DIE at 0x1b7 referenced from DIE at 0x11a [in module amd64-entry-value-paramref]
(gdb) 
...
Comment 6 Tom de Vries 2020-07-24 08:49:13 UTC
The simplest thing I can think of is to turn the internal error into a similarly-styled Dwarf error:
...
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 39ed455def..7726f193da 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -18900,9 +18900,7 @@ find_partial_die (sect_offset sect_off, int offset_in_dwz, str
uct dwarf2_cu *cu)
     }
 
   if (pd == NULL)
-    internal_error (__FILE__, __LINE__,
-                   _("could not find partial DIE %s "
-                     "in cache [from module %s]\n"),
+    error (_("Dwarf Error: Cannot not find DIE at %s [from module %s]\n"),
                    sect_offset_str (sect_off), bfd_get_filename (objfile->obfd));
   return { cu, pd };
 }
...
such that we have:
...
$ gdb amd64-entry-value-paramref 
Reading symbols from amd64-entry-value-paramref...
Dwarf Error: Cannot not find DIE at 0x1b7 [from module amd64-entry-value-paramref]

(No debugging symbols found in amd64-entry-value-paramref)
(gdb)
...
Comment 7 Tom de Vries 2020-07-24 09:04:36 UTC
So, the executable has the following CUs:
...
$ readelf -wi amd64-entry-value-paramref | grep -A4 DW_TAG_compile_unit | grep DW_AT_name
    <20>   DW_AT_name        : ../sysdeps/x86_64/start.S
    <3f>   DW_AT_name        : init.c
    <b9>   DW_AT_name        : ../sysdeps/x86_64/crti.S
    <d8>   DW_AT_name        : gdb.arch/amd64-entry-value-paramref.cc
    <1d3>   DW_AT_name       : elf-init.c
    <38e>   DW_AT_name       : ../sysdeps/x86_64/crtn.S
...

With -readnow we manage to keep the CUs that were read before running into the Dwarf Error:
...
$ gdb -batch -readnow amd64-entry-value-paramref -ex "maint info symtabs" | grep "{ symtab"
Dwarf Error: Cannot find DIE at 0x1b7 referenced from DIE at 0x11a [in module /home/vries/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.arch/amd64-entry-value-paramref/amd64-entry-value-paramref]
        { symtab ../sysdeps/x86_64/crti.S ((struct symtab *) 0x3b1d470)
        { symtab init.c ((struct symtab *) 0x3ae9600)
        { symtab ../sysdeps/x86_64/start.S ((struct symtab *) 0x3ae9350)
$
...

And without -readnow, we have no info at all:
...
$ gdb -batch amd64-entry-value-paramref -ex "maint info symtabs" | grep "{ psymtab"
Dwarf Error: Cannot not find DIE at 0x1b7 [from module /home/vries/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.arch/amd64-entry-value-paramref/amd64-entry-value-paramref]
$
...
Comment 8 Tom de Vries 2020-07-24 10:53:18 UTC
submitted: https://sourceware.org/pipermail/gdb-patches/2020-July/170831.html
Comment 9 Sourceware Commits 2020-08-04 09:16:40 UTC
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=521894aa4bf50ca6569844af0c604ee8d5ea4b44

commit 521894aa4bf50ca6569844af0c604ee8d5ea4b44
Author: Tom de Vries <tdevries@suse.de>
Date:   Tue Aug 4 11:16:37 2020 +0200

    [gdb/symtab] Handle invalid partial DIE reference
    
    When reverting commit 9cfd2b89bd "[gdb/testsuite] Fix
    gdb.arch/amd64-entry-value-paramref.S", we run into an internal-error:
    ...
    (gdb) file amd64-entry-value-paramref^M
    Reading symbols from amd64-entry-value-paramref...^M
    src/gdb/dwarf2/read.c:18903: internal-error: could not find partial DIE
      0x1b7 in cache [from module amd64-entry-value-paramref]^M
    
    A problem internal to GDB has been detected,^M
    further debugging may prove unreliable.^M
    ...
    because of invalid dwarf.
    
    In contrast, when using -readnow, we have:
    ...
    (gdb) file -readnow amd64-entry-value-paramref
    Reading symbols from amd64-entry-value-paramref...
    Expanding full symbols from amd64-entry-value-paramref...
    Dwarf Error: Cannot find DIE at 0x1b7 referenced from DIE at 0x11a \
      [in module amd64-entry-value-paramref]
    (gdb)
    ...
    
    Change the internal error into a Dwarf Error, such that we have:
    ...
    (gdb) file amd64-entry-value-paramref^M
    Reading symbols from amd64-entry-value-paramref...^M
    Dwarf Error: Cannot not find DIE at 0x1b7 \
      [from module amd64-entry-value-paramref]^M
    ^M
    (No debugging symbols found in amd64-entry-value-paramref)^M
    (gdb)
    ...
    
    Build and tested on x86_64-linux.
    
    gdb/ChangeLog:
    
    2020-08-04  Tom de Vries  <tdevries@suse.de>
    
            PR symtab/23270
            * dwarf2/read.c (find_partial_die): Change internal error into Dwarf
            Error.
Comment 10 Tom de Vries 2020-08-04 09:18:01 UTC
Patch committed, marking resolved-fixed.