Re: [PATCH] [PR 25678] gdb crashes with "internal-error: sect_index_text not initialized" when .text

Simon Marchi
2020-05-17T14:08:11Z

On 2020-05-17 10:01 a.m., Simon Marchi wrote:
> Thanks Andreas for the tip, I didn't think of checking the distro patches.
>
> I was able to reproduce with this:
>
> $ cat allo.c
> int salut;
> $ gcc allo.c -fPIC -o allo.o -g3 -O0 -c
> $ gcc allo.o -shared -nostdlib -nodefaultlibs -o allo.so
> $ ./gdb -q -nx a.out
> Reading symbols from a.out...
> (gdb) start
> Temporary breakpoint 1 at 0x1136: file test.c, line 1.
> Starting program: /home/smarchi/build/binutils-gdb/gdb/a.out
> /home/smarchi/src/binutils-gdb/gdb/objfiles.h:524: internal-error: sect_index_text not initialized
> A problem internal to GDB has been detected,
> further debugging may prove unreliable.
> Quit this debugging session? (y or n)
>
> Simon
>

Ah nevermind, I spoke to soon. I forgot to rebuild the main executable,
to I was still running some old test case. When doing that, it doesn't
hit the assert:

$ cat allo.c
int salut;
$ gcc allo.c -fPIC -o allo.o -g3 -O0 -c
$ gcc allo.o -shared -nostdlib -nodefaultlibs -o allo.so
$ cat test.c
int main() {}
$ gcc test.c -Wl,--no-as-needed ./allo.so -g3 -O0 -o
$ ./gdb --data-directory=data-directory -q -nx a.out
Reading symbols from a.out...
(gdb) start
Temporary breakpoint 1 at 0x1136: file test.c, line 1.
Starting program: /home/smarchi/build/binutils-gdb/gdb/a.out

Temporary breakpoint 1, main () at test.c:1
1 int main() {}
(gdb)

Simon