public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/29128] New: "internal-error: find_pc_sect_compunit_symtab: Assertion `result != nullptr' failed" while debugging asm program
@ 2022-05-07 11:49 simark at simark dot ca
  2022-05-07 12:07 ` [Bug gdb/29128] " simark at simark dot ca
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: simark at simark dot ca @ 2022-05-07 11:49 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 29128
           Summary: "internal-error: find_pc_sect_compunit_symtab:
                    Assertion `result != nullptr' failed" while debugging
                    asm program
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: simark at simark dot ca
  Target Milestone: ---

On Arch Linux:

$ cat readfile.asm 
            global _start

            section .text
_start:     mov     rax, 2
            mov     rdi, path
            xor     rsi, rsi
            syscall

            mov     rax, 60
            xor rdi, rdi
            syscall

            section .data
path:       db      "/etc/hosts", 0
$ nasm --version                        
NASM version 2.15.05 compiled on Sep 24 2020
$ nasm -f elf64 -F dwarf -g readfile.asm
$ ld --version             
GNU ld (GNU Binutils) 2.38
Copyright (C) 2022 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
$ ld readfile.o -o readfile
$ ~/build/binutils-gdb-one-target/gdb/gdb -nx -q
-data-directory=/home/simark/build/binutils-gdb-one-target/gdb/data-directory
readfile -ex starti -batch

This GDB supports auto-downloading debuginfo from the following URLs:
  <https://debuginfod.archlinux.org>
Enable debuginfod for this session? (y or [n]) [answered N; input not from
terminal]
Debuginfod has been disabled.
To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit.
/home/simark/src/binutils-gdb/gdb/dwarf2/read.c:18490: internal-error:
find_pc_sect_compunit_symtab: Assertion `result != nullptr' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.


#0  internal_error (file=0x55555de1b5e0
"/home/simark/src/binutils-gdb/gdb/dwarf2/read.c", line=18490,
fmt=0x55555de19060 "%s: Assertion `%s' failed.") at
/home/simark/src/binutils-gdb/gdbsupport/errors.cc:51
#1  0x000055556050bf3c in cooked_index_functions::find_pc_sect_compunit_symtab
(this=0x60200007f190, objfile=0x6130000057c0, msymbol=..., pc=0x401000,
section=0x0, warn_if_readin=1) at
/home/simark/src/binutils-gdb/gdb/dwarf2/read.c:18490
#2  0x0000555561933a80 in objfile::find_pc_sect_compunit_symtab
(this=0x6130000057c0, msymbol=..., pc=0x401000, section=0x0, warn_if_readin=1)
at /home/simark/src/binutils-gdb/gdb/symfile-debug.c:447
#3  0x0000555561a02ce5 in find_pc_sect_compunit_symtab (pc=0x401000,
section=0x0) at /home/simark/src/binutils-gdb/gdb/symtab.c:3017
#4  0x000055555f965339 in blockvector_for_pc_sect (pc=0x401000, section=0x0,
pblock=0x7fffffffc0b0, cust=0x0) at
/home/simark/src/binutils-gdb/gdb/block.c:195
#5  0x000055555f965711 in block_for_pc_sect (pc=0x401000, section=0x0) at
/home/simark/src/binutils-gdb/gdb/block.c:273
#6  0x000055555f9657d2 in block_for_pc (pc=0x401000) at
/home/simark/src/binutils-gdb/gdb/block.c:285
#7  0x0000555560c1a046 in skip_inline_frames (thread=0x617000033700,
stop_chain=0x0) at /home/simark/src/binutils-gdb/gdb/inline-frame.c:353
#8  0x0000555560b9678e in handle_signal_stop (ecs=0x7fffffffca10) at
/home/simark/src/binutils-gdb/gdb/infrun.c:6327
#9  0x0000555560b90779 in handle_inferior_event (ecs=0x7fffffffca10) at
/home/simark/src/binutils-gdb/gdb/infrun.c:5855
#10 0x0000555560b7c916 in fetch_inferior_event () at
/home/simark/src/binutils-gdb/gdb/infrun.c:4221
#11 0x0000555560ac838e in inferior_event_handler (During symbol reading: bad
file number in macro information (299)
event_type=INF_REG_EVENT) at /home/simark/src/binutils-gdb/gdb/inf-loop.c:41
#12 0x0000555560d9454f in handle_target_event (error=0, client_data=0x0) at
/home/simark/src/binutils-gdb/gdb/linux-nat.c:4136
#13 0x000055556253bf6b in handle_file_event (file_ptr=0x607000014d10,
ready_mask=1) at /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:574
#14 0x000055556253c8a6 in gdb_wait_for_event (block=0) at
/home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:700
#15 0x000055556253a5e5 in gdb_do_one_event () at
/home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:212
#16 0x0000555561ca74b7 in wait_sync_command_done () at
/home/simark/src/binutils-gdb/gdb/top.c:553
#17 0x0000555561ca76cf in maybe_wait_sync_command_done (was_sync=0) at
/home/simark/src/binutils-gdb/gdb/top.c:570
#18 0x0000555561ca8ba3 in execute_command (p=0x7fffffffe1b3 "", from_tty=0) at
/home/simark/src/binutils-gdb/gdb/top.c:701
#19 0x0000555560e93d27 in catch_command_errors (command=0x555561ca76ec
<execute_command(char const*, int)>, arg=0x7fffffffe1ad "starti", from_tty=0,
do_bp_actions=true) at /home/simark/src/binutils-gdb/gdb/main.c:515
#20 0x0000555560e945c4 in execute_cmdargs (cmdarg_vec=0x7fffffffd730,
file_type=CMDARG_FILE, cmd_type=CMDARG_COMMAND, ret=0x7fffffffd3f0) at
/home/simark/src/binutils-gdb/gdb/main.c:610
#21 0x0000555560e987b6 in captured_main_1 (context=0x7fffffffdbd0) at
/home/simark/src/binutils-gdb/gdb/main.c:1304
#22 0x0000555560e98dc2 in captured_main (data=0x7fffffffdbd0) at
/home/simark/src/binutils-gdb/gdb/main.c:1325
#23 0x0000555560e98ea4 in gdb_main (args=0x7fffffffdbd0) at
/home/simark/src/binutils-gdb/gdb/main.c:1350
#24 0x000055555f568a39 in main (argc=8, argv=0x7fffffffdd68) at
/home/simark/src/binutils-gdb/gdb/gdb.c:32

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

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

* [Bug gdb/29128] "internal-error: find_pc_sect_compunit_symtab: Assertion `result != nullptr' failed" while debugging asm program
  2022-05-07 11:49 [Bug gdb/29128] New: "internal-error: find_pc_sect_compunit_symtab: Assertion `result != nullptr' failed" while debugging asm program simark at simark dot ca
@ 2022-05-07 12:07 ` simark at simark dot ca
  2022-05-07 15:06 ` tromey at sourceware dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: simark at simark dot ca @ 2022-05-07 12:07 UTC (permalink / raw)
  To: gdb-prs

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

Simon Marchi <simark at simark dot ca> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org

--- Comment #1 from Simon Marchi <simark at simark dot ca> ---
Bisects to

commit 3d20b8d99a54382e6e1a6c433e71e0775c6856c6
Author: Tom Tromey <tom@tromey.com>
Date:   Sun Apr 18 14:08:54 2021 -0600

    Enable the new DWARF indexer

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

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

* [Bug gdb/29128] "internal-error: find_pc_sect_compunit_symtab: Assertion `result != nullptr' failed" while debugging asm program
  2022-05-07 11:49 [Bug gdb/29128] New: "internal-error: find_pc_sect_compunit_symtab: Assertion `result != nullptr' failed" while debugging asm program simark at simark dot ca
  2022-05-07 12:07 ` [Bug gdb/29128] " simark at simark dot ca
@ 2022-05-07 15:06 ` tromey at sourceware dot org
  2022-05-07 15:25 ` tromey at sourceware dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: tromey at sourceware dot org @ 2022-05-07 15:06 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at sourceware dot org   |tromey at sourceware dot org

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

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

* [Bug gdb/29128] "internal-error: find_pc_sect_compunit_symtab: Assertion `result != nullptr' failed" while debugging asm program
  2022-05-07 11:49 [Bug gdb/29128] New: "internal-error: find_pc_sect_compunit_symtab: Assertion `result != nullptr' failed" while debugging asm program simark at simark dot ca
  2022-05-07 12:07 ` [Bug gdb/29128] " simark at simark dot ca
  2022-05-07 15:06 ` tromey at sourceware dot org
@ 2022-05-07 15:25 ` tromey at sourceware dot org
  2022-05-07 20:45 ` simark at simark dot ca
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: tromey at sourceware dot org @ 2022-05-07 15:25 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
gdb shouldn't crash here, but also this file is weird.

The .debug_info says:

 <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <c>   DW_AT_low_pc      : 0x4000b0
    <14>   DW_AT_high_pc     : 0x4000b0

and

 <1><3c>: Abbrev Number: 2 (DW_TAG_subprogram)
    <3d>   DW_AT_low_pc      : 0x4000b0

(no high PC for the function)

However, aranges says:

    Address            Length
    00000000004000b0 000000000000001e 

The cooked index uses aranges if it is available.
So, the initial code in cooked_index_functions::find_pc_sect_compunit_symtab
finds the requested PC (0x4000b0) in one of the addrmaps.

However, after expanding CUs, recursively_find_pc_sect_compunit_symtab
does not find this PC, because it doesn't appear in the blockvector.

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

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

* [Bug gdb/29128] "internal-error: find_pc_sect_compunit_symtab: Assertion `result != nullptr' failed" while debugging asm program
  2022-05-07 11:49 [Bug gdb/29128] New: "internal-error: find_pc_sect_compunit_symtab: Assertion `result != nullptr' failed" while debugging asm program simark at simark dot ca
                   ` (2 preceding siblings ...)
  2022-05-07 15:25 ` tromey at sourceware dot org
@ 2022-05-07 20:45 ` simark at simark dot ca
  2022-05-21 14:57 ` tromey at sourceware dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: simark at simark dot ca @ 2022-05-07 20:45 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #3 from Simon Marchi <simark at simark dot ca> ---
(In reply to Tom Tromey from comment #2)
> gdb shouldn't crash here, but also this file is weird.
> 
> The .debug_info says:
> 
>  <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
>     <c>   DW_AT_low_pc      : 0x4000b0
>     <14>   DW_AT_high_pc     : 0x4000b0
> 
> and
> 
>  <1><3c>: Abbrev Number: 2 (DW_TAG_subprogram)
>     <3d>   DW_AT_low_pc      : 0x4000b0
> 
> (no high PC for the function)

Agreed, looks like bad debug info.

On Ubuntu 20.04, with NASM version 2.14.02, at least the CU's high pc is right:

0x0000000b: DW_TAG_compile_unit
              DW_AT_low_pc [DW_FORM_addr]       (0x0000000000401000)
              DW_AT_high_pc [DW_FORM_addr]      (0x000000000040101e)

The original report on IRC was about GDB not showing the lines when stepping. 
The root cause must be this NASM bug.  I think it's ok to not produce good
results when working with the bad debug info, but ideally we wouldn't crash.

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

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

* [Bug gdb/29128] "internal-error: find_pc_sect_compunit_symtab: Assertion `result != nullptr' failed" while debugging asm program
  2022-05-07 11:49 [Bug gdb/29128] New: "internal-error: find_pc_sect_compunit_symtab: Assertion `result != nullptr' failed" while debugging asm program simark at simark dot ca
                   ` (3 preceding siblings ...)
  2022-05-07 20:45 ` simark at simark dot ca
@ 2022-05-21 14:57 ` tromey at sourceware dot org
  2022-05-26 17:50 ` cvs-commit at gcc dot gnu.org
  2022-05-26 17:51 ` tromey at sourceware dot org
  6 siblings, 0 replies; 8+ messages in thread
From: tromey at sourceware dot org @ 2022-05-21 14:57 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #4 from Tom Tromey <tromey at sourceware dot org> ---
https://sourceware.org/pipermail/gdb-patches/2022-May/189017.html

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

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

* [Bug gdb/29128] "internal-error: find_pc_sect_compunit_symtab: Assertion `result != nullptr' failed" while debugging asm program
  2022-05-07 11:49 [Bug gdb/29128] New: "internal-error: find_pc_sect_compunit_symtab: Assertion `result != nullptr' failed" while debugging asm program simark at simark dot ca
                   ` (4 preceding siblings ...)
  2022-05-21 14:57 ` tromey at sourceware dot org
@ 2022-05-26 17:50 ` cvs-commit at gcc dot gnu.org
  2022-05-26 17:51 ` tromey at sourceware dot org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-26 17:50 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #5 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom Tromey <tromey@sourceware.org>:

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

commit 834eaf9201c18efc5b888f3cd116dd7856bec759
Author: Tom Tromey <tom@tromey.com>
Date:   Thu May 12 16:37:52 2022 -0600

    Fix crash in new DWARF indexer

    PR gdb/29128 points out a crash in the new DWARF index code.  This
    happens if the aranges for a CU claims a PC, but the symtab that is
    created during CU expansion does not actually contain the PC.  This
    can only occur due to bad debuginfo, but at the same time, gdb should
    not crash.

    This patch fixes the bug and further merges some code into
    dwarf2_base_index_functions.  This merger helps prevent the same issue
    from arising from the other index implementations.

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

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

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

* [Bug gdb/29128] "internal-error: find_pc_sect_compunit_symtab: Assertion `result != nullptr' failed" while debugging asm program
  2022-05-07 11:49 [Bug gdb/29128] New: "internal-error: find_pc_sect_compunit_symtab: Assertion `result != nullptr' failed" while debugging asm program simark at simark dot ca
                   ` (5 preceding siblings ...)
  2022-05-26 17:50 ` cvs-commit at gcc dot gnu.org
@ 2022-05-26 17:51 ` tromey at sourceware dot org
  6 siblings, 0 replies; 8+ messages in thread
From: tromey at sourceware dot org @ 2022-05-26 17:51 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

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

--- Comment #6 from Tom Tromey <tromey at sourceware dot org> ---
Fixed.

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

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

end of thread, other threads:[~2022-05-26 17:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-07 11:49 [Bug gdb/29128] New: "internal-error: find_pc_sect_compunit_symtab: Assertion `result != nullptr' failed" while debugging asm program simark at simark dot ca
2022-05-07 12:07 ` [Bug gdb/29128] " simark at simark dot ca
2022-05-07 15:06 ` tromey at sourceware dot org
2022-05-07 15:25 ` tromey at sourceware dot org
2022-05-07 20:45 ` simark at simark dot ca
2022-05-21 14:57 ` tromey at sourceware dot org
2022-05-26 17:50 ` cvs-commit at gcc dot gnu.org
2022-05-26 17:51 ` tromey at sourceware dot 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).