Bug 27353

Summary: [gcc-11] attribute.h:258: internal-error: void attribute::set_unsigned_reprocess(ULONGEST): Assertion `form_requires_reprocessing ()' failed.
Product: gdb Reporter: Tom de Vries <vries>
Component: symtabAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: HEAD   
Target Milestone: 11.1   
Host: Target:
Build: Last reconfirmed:
Project(s) to access: ssh public key:

Description Tom de Vries 2021-02-05 15:09:14 UTC
When running test-case gdb.dwarf2/fission-mix.exp using gcc-11, I run into:
...
(gdb) file fission-mix^M
Reading symbols from fission-mix...^M
src/gdb/dwarf2/attribute.h:258: internal-error: void attribute::set_unsigned_reprocess(ULONGEST): Assertion `form_requires_reprocessing ()' failed.^M
...

So, this happens with DW_FORM_strx:
...
(gdb) 
#6  0x00000000006624a8 in attribute::set_unsigned_reprocess (this=0x20c1868, unsnd=3)
    at /home/vries/gdb_versions/devel/src/gdb/dwarf2/attribute.h:258
258         gdb_assert (form_requires_reprocessing ());
(gdb) p *this
$1 = {name = DW_AT_producer, requires_reprocessing = 0, form = DW_FORM_strx, 
  string_is_canonical = 0, u = {str = 0x0, blk = 0x0, unsnd = 0, snd = 0, addr = 0, 
    signature = 0}}
...
Comment 1 Tom de Vries 2021-02-05 15:20:09 UTC
Looks like an oversight, this fixes it:
...
diff --git a/gdb/dwarf2/attribute.c b/gdb/dwarf2/attribute.c
index 8c58f1bcd9f..6b8d5419178 100644
--- a/gdb/dwarf2/attribute.c
+++ b/gdb/dwarf2/attribute.c
@@ -200,7 +200,8 @@ attribute::form_is_signed () const
 bool
 attribute::form_requires_reprocessing () const
 {
-  return (form == DW_FORM_strx1
+  return (form == DW_FORM_strx
+         || form == DW_FORM_strx1
          || form == DW_FORM_strx2
          || form == DW_FORM_strx3
          || form == DW_FORM_strx4
...
Comment 3 Sourceware Commits 2021-02-11 20:03:07 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=05f68f52ef0dc3cc52ee5886509a83f159224eb8

commit 05f68f52ef0dc3cc52ee5886509a83f159224eb8
Author: Tom de Vries <tdevries@suse.de>
Date:   Thu Feb 11 21:03:03 2021 +0100

    [gdb/symtab] Handle DW_FORM_strx in form_requires_reprocessing
    
    When running test-case gdb.dwarf2/fission-mix.exp using gcc-11, I run into:
    ...
    (gdb) file fission-mix^M
    Reading symbols from fission-mix...^M
    src/gdb/dwarf2/attribute.h:258: internal-error: \
      void attribute::set_unsigned_reprocess(ULONGEST): \
      Assertion `form_requires_reprocessing ()' failed.^M
    ...
    
    This happens when calling set_unsigned_reprocess on an attribute with form
    DW_FORM_strx.  The assert triggers because DW_FORM_strx is not listed in
    form_requires_reprocessing.
    
    Fix this by adding DW_FORM_strx in form_requires_reprocessing.
    
    Tested on x86_64-linux.
    
    gdb/ChangeLog:
    
    2021-02-11  Tom de Vries  <tdevries@suse.de>
    
            PR symtab/27353
            * dwarf2/attribute.c (attribute::form_requires_reprocessing):
            Return true for DW_FORM_strx.
Comment 4 Tom de Vries 2021-02-11 20:03:47 UTC
Patch committed, marking resolved-fixed.