We've run into an assertion failure when quitting GDB after stepping
past the end of a program that was linked with stripped libraries.
Here's how it's triggered, using a simple factorial example for
nios2-linux-gnu target with gdbserver:
Breakpoint 1, main () at /home/sandra/examples/fact.c:13
13 for (i = 0; i < 10; ++i) {
(gdb) advance 17
main () at /home/sandra/examples/fact.c:17
17 return 0;
(gdb) s
18 }
(gdb) s
0x2aaefffc in __libc_start_main ()
from
/./scratch/sandra/nios2-linux-spring-release/install/opt/codesourcery/nios2-linux-gnu/libc//lib/libc.so.6
(gdb) s
Single stepping until exit from function __libc_start_main,
which has no line number information.
[Inferior 1 (process 15772) exited normally]
You can't do that without a process to debug.
(gdb) s
The program is not being run.
(gdb) quit
/scratch/sandra/nios2-linux-fsf/obj/gdb-src-mainline-0-nios2-linux-gnu-x86_64-linux-gnu/gdb/inferior.c:287:
internal-error: inferior* find_inferior_pid(int): Assertion `pid != 0'
failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
The attached 1-liner patch fixes it and didn't cause regressions
elsewhere. However, I'm not sure if this is really where the bug is.
Maybe some other state is not getting cleaned out when the inferior
exits? WDYT?