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
Bisects to commit 3d20b8d99a54382e6e1a6c433e71e0775c6856c6 Author: Tom Tromey <tom@tromey.com> Date: Sun Apr 18 14:08:54 2021 -0600 Enable the new DWARF indexer
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.
(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.
https://sourceware.org/pipermail/gdb-patches/2022-May/189017.html
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
Fixed.