public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug symtab/27919] New: [gdb/symtab] segfault in process_psymtab_comp_unit
@ 2021-05-27  9:33 vries at gcc dot gnu.org
  2021-05-27 10:03 ` [Bug symtab/27919] " vries at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2021-05-27  9:33 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27919

            Bug ID: 27919
           Summary: [gdb/symtab] segfault in process_psymtab_comp_unit
           Product: gdb
           Version: 10.1
            Status: NEW
          Severity: normal
          Priority: P2
         Component: symtab
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

With this test-case patch:
...
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-dummy-cu.exp
b/gdb/testsuite/gdb.dwarf2/dw2-dummy
-cu.exp
index 673972447a1..ba3ccd4ff28 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}" ob
ject {}] != "
     return -1
 }

-set saved_gdbflags $GDBFLAGS
-set GDBFLAGS "$GDBFLAGS -readnow"
-
 clean_restart $executable

 # 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
...
we run into:
...
(gdb) file
/home/vries/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.dwarf2/dw2-dummy-cu/dw2-dummy-cu^M
Reading symbols from
/home/vries/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.dwarf2/dw2-dummy-cu/dw2-dummy-cu...^M
ERROR: Couldn't load dw2-dummy-cu into GDB (eof).
...

On the command line:
...
$ gdb -q -batch ./outputs/gdb.dwarf2/dw2-dummy-cu/dw2-dummy-cu 
Aborted (core dumped)
...

Using gdb:
...
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)
(gdb) p reader.comp_unit_die
$1 = (die_info *) 0x0
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug symtab/27919] [gdb/symtab] segfault in process_psymtab_comp_unit
  2021-05-27  9:33 [Bug symtab/27919] New: [gdb/symtab] segfault in process_psymtab_comp_unit vries at gcc dot gnu.org
@ 2021-05-27 10:03 ` vries at gcc dot gnu.org
  2021-05-27 13:22 ` cvs-commit at gcc dot gnu.org
  2021-05-27 13:23 ` vries at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2021-05-27 10:03 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27919

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
Indeed, no CU DIE:
...
$ 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
$
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug symtab/27919] [gdb/symtab] segfault in process_psymtab_comp_unit
  2021-05-27  9:33 [Bug symtab/27919] New: [gdb/symtab] segfault in process_psymtab_comp_unit vries at gcc dot gnu.org
  2021-05-27 10:03 ` [Bug symtab/27919] " vries at gcc dot gnu.org
@ 2021-05-27 13:22 ` cvs-commit at gcc dot gnu.org
  2021-05-27 13:23 ` vries at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-27 13:22 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27919

--- Comment #2 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

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

commit 248f7165005096fc618c5fd9bf3588719fc589ef
Author: Tom de Vries <tdevries@suse.de>
Date:   Thu May 27 15:22:38 2021 +0200

    [gdb/symtab] Fix segfault in process_psymtab_comp_unit

    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.

    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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug symtab/27919] [gdb/symtab] segfault in process_psymtab_comp_unit
  2021-05-27  9:33 [Bug symtab/27919] New: [gdb/symtab] segfault in process_psymtab_comp_unit vries at gcc dot gnu.org
  2021-05-27 10:03 ` [Bug symtab/27919] " vries at gcc dot gnu.org
  2021-05-27 13:22 ` cvs-commit at gcc dot gnu.org
@ 2021-05-27 13:23 ` vries at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2021-05-27 13:23 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27919

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |11.1

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
Patch committed, marking resolved-fixed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-27 13:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-27  9:33 [Bug symtab/27919] New: [gdb/symtab] segfault in process_psymtab_comp_unit vries at gcc dot gnu.org
2021-05-27 10:03 ` [Bug symtab/27919] " vries at gcc dot gnu.org
2021-05-27 13:22 ` cvs-commit at gcc dot gnu.org
2021-05-27 13:23 ` vries at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).