gdb 5.3 (& earlier): Crash with mixed debug formats

Richard Dawe
2002-12-24T10:54:25Z

Hello.

I discovered recently that the DJGPP port of gdb crashes, when you have a mix
stabs+ and DWARF-2 debug information and try to tab-complete a function name.

First, here are some relevant version:

bash-2.04$ /djgpp.204/bin/gdb.exe --version
GNU gdb 5.3
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i686-pc-msdosdjgpp --target=djgpp".
bash-2.04$ gcc --version
gcc.exe (GCC) 3.2.1
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

bash-2.04$ as --version
GNU assembler 2.13
Copyright 2002 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License. This program has absolutely no warranty.
This assembler was configured for a target of `i386-pc-msdosdjgpp'.

Please find at the end of this mail a small test program that exhibits the
problem with the DJGPP ports of gdb 5.1.1, gdb 5.2.1 and gdb 5.3. Start up gdb
on the test program and do 'b d<TAB>'. gdb crashed for me doing tab
completion.

Here's a backtrace:

There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i686-pc-msdosdjgpp --target=djgpp"...
(gdb) b dExiting due to signal SIGSEGV
Page fault at eip=001862c6, error=0004
eax=ff00ff64 ebx=ff00ffff ecx=00000001 edx=00000000 esi=00256952 edi=00256952
ebp=00256868 esp=00256860 program=C:\DJGPP.204\BIN\GDB.EXE
cs: sel=00f7 base=84188000 limit=ffb83fff
ds: sel=00ff base=84188000 limit=ffb83fff
es: sel=00ff base=84188000 limit=ffb83fff
fs: sel=00d7 base=00018ba0 limit=0000ffff
gs: sel=010f base=00000000 limit=0010ffff
ss: sel=00ff base=84188000 limit=ffb83fff
App stack: [00257134..001d7134] Exceptn stack: [001d6768..001d4828]

Call frame traceback EIPs:
0x001862c6 strncmp+22, file strncmp.c
0x000415dd completion_list_add_name+29, file
c:/djgpp.204/gnu/gdb-5.3/gdb/symtab.c, line 3173
0x000418de make_symbol_completion_list+494, file
c:/djgpp.204/gnu/gdb-5.3/gdb/symtab.c, line 3316
0x0003d2d9 .debug_line+6, file c:/djgpp.204/gnu/gdb-5.3/gdb/completer.c,
line 286
0x0003d4ab .debug_frame+15, file c:/djgpp.204/gnu/gdb-5.3/gdb/completer.c,
line 602
0x0003d773 line_completion_function+51, file
c:/djgpp.204/gnu/gdb-5.3/gdb/completer.c, line 651
0x0003cedf readline_line_completion_function+31, file
c:/djgpp.204/gnu/gdb-5.3/gdb/completer.c, line 110
0x0015258f completion_matches+47, file
c:/djgpp.204/gnu/gdb-5.3/readline/complete.c, line 1389
0x00151713 gen_completion_matches+51, file
c:/djgpp.204/gnu/gdb-5.3/readline/complete.c, line 707
0x00152344 rl_complete_internal+148, file
c:/djgpp.204/gnu/gdb-5.3/readline/complete.c, line 1265
0x0014ac7a _rl_dispatch+170, file
c:/djgpp.204/gnu/gdb-5.3/readline/readline.c, line 533
0x0014aa06 readline_internal_char+134, file
c:/djgpp.204/gnu/gdb-5.3/readline/readline.c, line 411
0x00155f34 rl_callback_read_char+20, file
c:/djgpp.204/gnu/gdb-5.3/readline/callback.c, line 105
0x00087f0a rl_callback_read_char_wrapper+10, file
c:/djgpp.204/gnu/gdb-5.3/gdb/event-top.c, line 169
0x000884ae stdin_event_handler+94, file
c:/djgpp.204/gnu/gdb-5.3/gdb/event-top.c, line 418
0x0008774c handle_file_event+92, file
c:/djgpp.204/gnu/gdb-5.3/gdb/event-loop.c, line 714
0x00087274 process_event+68, file c:/djgpp.204/gnu/gdb-5.3/gdb/event-loop.c,
line 335
0x000872c6 gdb_do_one_event+54, file
c:/djgpp.204/gnu/gdb-5.3/gdb/event-loop.c, line 371
0x0001418f do_catch_errors+15, file c:/djgpp.204/gnu/gdb-5.3/gdb/top.c, line
493
0x00014090 catcher+272, file c:/djgpp.204/gnu/gdb-5.3/gdb/top.c, line 424
0x000141d6 .debug_pubnames+44, file c:/djgpp.204/gnu/gdb-5.3/gdb/top.c, line
505
0x000872e8 start_event_loop+24, file
c:/djgpp.204/gnu/gdb-5.3/gdb/event-loop.c, line 396
0x00001794 .debug_aranges+20, file c:/djgpp.204/gnu/gdb-5.3/gdb/main.c, line
96
0x0001418f do_catch_errors+15, file c:/djgpp.204/gnu/gdb-5.3/gdb/top.c, line
493
0x00014090 catcher+272, file c:/djgpp.204/gnu/gdb-5.3/gdb/top.c, line 424
0x000141d6 .debug_pubnames+44, file c:/djgpp.204/gnu/gdb-5.3/gdb/top.c, line
505
0x000024bb .debug_frame+19, file c:/djgpp.204/gnu/gdb-5.3/gdb/main.c, line
729
0x0001418f do_catch_errors+15, file c:/djgpp.204/gnu/gdb-5.3/gdb/top.c, line
493
0x00014090 catcher+272, file c:/djgpp.204/gnu/gdb-5.3/gdb/top.c, line 424
0x000141d6 .debug_pubnames+44, file c:/djgpp.204/gnu/gdb-5.3/gdb/top.c, line
505
0x000025d2 gdb_main+34, file c:/djgpp.204/gnu/gdb-5.3/gdb/main.c, line 740
0x00001748 .debug_aranges+8
0x00185117 __crt1_startup+199, file crt1.c

In earlier debugging session, I found that the for loop at gdb/symtab.c:3306
(gdb 5.3 sources) eventually leads to a protection fault.

I tried to debug gdb with gdb, to give a gdb backtrace, but I couldn't make
the debugged gdb segfault. Typical. gdb did crash with a backtrace like above
every time I tried it.

I also tried to reproduce the problem on RedHat Linux 6.2, but it did not
crash. Versions:

iolanthe:~/src/gdb/mixed-format =] /usr/local/src/gdb-5.3/gdb/gdb --version
GNU gdb 5.3
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i586-pc-linux-gnu".
iolanthe:~/src/gdb/mixed-format =] gcc --version
egcs-2.91.66
iolanthe:~/src/gdb/mixed-format =] as --version
GNU assembler 2.9.5
Copyright 1997 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License. This program has absolutely no warranty.
This assembler was configured for a target of `i386-redhat-linux'.

Please let me know if more information is required.

Thanks, regards,

--
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]

---Start Makefile---
CC = gcc

default: test

dwarfed.o: dwarfed.c
$(CC) -gdwarf-2 -Wall -o $@ -c $<

stabsed.o: stabsed.c
$(CC) -gstabs+ -Wall -o $@ -c $<

test.o: test.c
$(CC) -Wall -o $@ -c $<

test: dwarfed.o stabsed.o test.o
$(CC) -g -o $@ $^
---End Makefile---

---Start dwarfed.c---
#include <stdio.h>

void
dwarfed (void)
{
puts("dwarfed");
}
---End dwarfed.c---

---Start stabsed.c---
#include <stdio.h>

void
stabsed (void)
{
puts("stabsed");
}
---End stabsed.c---

---Start test.c---
#include <stdlib.h>

extern void dwarfed (void);
extern void stabsed (void);

int
main (void)
{
dwarfed();
stabsed();

return(EXIT_SUCCESS);
}
---End test.c---