FS#77971 - [gdb] internal-error: inside_main_func: Assertion `block != nullptr' failed

Attached to Project: Arch Linux
Opened by Jonas Malaco Filho (jonasmalaco) - Thursday, 23 March 2023, 17:35 GMT
Last edited by Anatol Pomozov (anatolik) - Friday, 24 March 2023, 20:45 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Anatol Pomozov (anatolik)
Levente Polyak (anthraxx)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description: a simple rust program compiled with cargo causes an internal gdb assertion to fail while backtracing from a segfault.

Additional info:
* package version(s): gdb 13.1-1, rustup 1.25.2-1 (using the current stable toolchain, 1.68.1)
* config and/or log files etc.: N/A, reproduces with `gdb --nh ...`
* link to upstream bug report, if any

A similar bug report has been filed for Debian:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1031745

It seems that they have patched this issue on their end (but I haven't tested it).

Steps to reproduce:

1. Create a sample `crashing` project with cargo (it's important to use cargo to build the project):

$ cargo new crashing

2. Add the following code to `main.rs`:

// main.rs
use std::sync::Once;
static INIT: Once = Once::new();
fn main() {
INIT.call_once(|| unsafe {
*(0xaabbccdd as *mut usize) = 1234;
});
}

2. Compile and run with gdb:

$ cargo b
Finished dev [unoptimized + debuginfo] target(s) in 0.00s

$ gdb target/debug/crashing
GNU gdb (GDB) 13.1
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from target/debug/crashing...
warning: Missing auto-load script at offset 0 in section .debug_gdb_scripts
of file /tmp/crashing/target/debug/crashing.
Use `info auto-load python-scripts [REGEXP]' to list them.
(gdb) r
Starting program: /tmp/crashing/target/debug/crashing

This GDB supports auto-downloading debuginfo from the following URLs:
<https://debuginfod.archlinux.org>
Enable debuginfod for this session? (y or [n])
Debuginfod has been disabled.
To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x0000555555569e86 in crashing::main::{closure#0} () at src/main.rs:7
7 *(0xaabbccdd as *mut usize) = 1234;
(gdb) bt
../../gdb/frame.c:2457: internal-error: inside_main_func: Assertion `block != nullptr' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
----- Backtrace -----
0x559f46830d7b ???
0x559f46be0db4 ???
0x559f46cc45a3 ???
0x559f469729f6 ???
0x559f46ab2caf ???
0x559f46ab5ee2 ???
0x559f46941bb1 ???
0x559f46b4cbe5 ???
0x559f46871b14 ???
0x559f46bac9d3 ???
0x559f469439cc ???
0x559f46943a70 ???
0x559f4693ecdf ???
0x7f1d03c09246 ???
0x559f46942183 ???
0x559f46942303 ???
0x559f4694392f ???
0x559f46cc4e2d ???
0x559f46d165c9 ???
0x559f46a414d4 ???
0x559f4679c654 ???
0x7f1d02e3c78f ???
0x7f1d02e3c849 ???
0x559f467a3ab4 ???
0xffffffffffffffff ???
---------------------
../../gdb/frame.c:2457: internal-error: inside_main_func: Assertion `block != nullptr' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
This task depends upon

Closed by  Anatol Pomozov (anatolik)
Friday, 24 March 2023, 20:45 GMT
Reason for closing:  Fixed
Additional comments about closing:  13.1-2
Comment by loqs (loqs) - Thursday, 23 March 2023, 19:52 GMT
Attached diff applies the fix for the 13.1 branch [1] linked in the upstream bug report [2]. Does rebuilding with the patch applied resolve the issue for you jonasmalaco?

[1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=562403d4f5483e0787219fdb88da72c707c8d7f6
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=30158
Comment by Jonas Malaco Filho (jonasmalaco) - Friday, 24 March 2023, 02:52 GMT
Thanks, I failed to find that upstream issue and patch before. And yes, the patch resolves the issue for me.

Thanks again!
Comment by Anatol Pomozov (anatolik) - Friday, 24 March 2023, 16:37 GMT
Thank you Ioqs and Jonas. The patch looks good to me. I am preparing gdb-13.1-2 which will be available in [testing] soon.

Please test 13.1-2 and let me know if you see any issues with it.
Comment by Jonas Malaco Filho (jonasmalaco) - Friday, 24 March 2023, 18:28 GMT
Seems to be working. Thanks!

Loading...