[Bug gdb/33481] GDB crashes upon target remote :1234 for ppc64le guest vm
vishalc at linux dot ibm.com
sourceware-bugzilla@sourceware.org
Fri Oct 10 05:57:29 GMT 2025
https://sourceware.org/bugzilla/show_bug.cgi?id=33481
--- Comment #14 from Vishal Chourasia <vishalc at linux dot ibm.com> ---
So far...
GDB crashes with a segmentation fault when attempting to connect to a remote
target (e.g., `target remote :1234`) while debugging the Linux kernel
(`vmlinux`) ARCH=powerpc
## Root Cause
The Linux kernel binary (`vmlinux`) contains a `.interp` section that exists
but is completely empty (size = 0). This causes a chain of failures:
1. `bfd_get_section_by_name()` successfully finds the `.interp` section
(returns non-NULL)
2. `bfd_section_size(interp_sect)` returns **0**
3. An empty `gdb::byte_vector buf(0)` is created
4. `bfd_get_section_contents()` returns **true** (reading 0 bytes always
succeeds)
5. The empty byte vector is returned from `find_program_interpreter()`
6. Calling code at line 2313 attempts to use `interp_name_holder->data()` as a
C string
7. Since the buffer is empty, this results in a **NULL or invalid pointer**
8. `solib_bfd_open()` crashes when trying to open a file with a NULL/empty path
- `vmlinux` is a **statically-linked kernel binary**, not a userspace program
- The empty `.interp` section is likely a linker artifact
Verification:
```bash
(i) ❯ llvm-readelf -S vmlinux | grep -E '(\.interp)|Name'
[Nr] Name Type Address Off Size ES Flg
Lk Inf Al
[46] .interp PROGBITS c0000000033d06f4 33e06f4 000000 00 A
0 0 1
```
## The Bug in GDB Code
In `gdb/solib-svr4.c` around line 605:
```c
interp_sect = bfd_get_section_by_name (current_program_space->exec_bfd (),
".interp");
if (interp_sect != NULL)
{
int sect_size = bfd_section_size (interp_sect); // Returns 0
gdb::byte_vector buf (sect_size); // Creates empty buffer
bool res
= bfd_get_section_contents (current_program_space->exec_bfd (),
interp_sect, buf.data (), 0, sect_size);
if (res) // Returns TRUE for 0-byte read
return buf; // Returns EMPTY buffer - BUG!
}
```
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Gdb-prs
mailing list