From: dwex@mtgzy.UUCP
Subject: GDB 4.6 core dump reading dynamically-loaded object symtab
Organization: GNUs Not Usenet
Distribution: gnu
Date: Mon, 17 Aug 1992 20:29:10 GMT

GDB version: 4.6
Architecture/OS: Sun SparcStation ELC/SunOS 4.1.1
GDB Compiled With: GCC 2.2.2 (with demangling patch applied)
Application Compiled With: Unknown (probably stock Sun cc)

Description:
	Used the 'sharedlibrary' command to force loading of dynamically
	loaded object libraries in an Andrew application, after the
	application died with a SIGSEGV.  GDB dropped core with
	SIGSEGV, dereferencing through a null pointer.  Here's
	the stack backtrace:

-----------------------------------------------------------------------------
#0  0x776e4 in read_dbx_symtab (section_offsets=0x42d0f0, objfile=0x41b308, 
    text_addr=0, text_size=8192) at ../../gdb-4.6/gdb/partial-stab.h:518
#1  0x7412c in dbx_symfile_read (objfile=0x41b308, section_offsets=0x42d0f0, 
    mainline=0) at ../../gdb-4.6/gdb/dbxread.c:482
#2  0x36960 in syms_from_objfile (objfile=0x41b308, addr=4149805056, 
    mainline=0, verbo=0) at ../../gdb-4.6/gdb/symfile.c:450
#3  0x36cd0 in symbol_file_add (
    name=0x35f434 "/usr/add-on/andrew/dlib/atk/glist.do", from_tty=0, 
    addr=4149805056, mainline=0, mapped=0, readnow=0)
    at ../../gdb-4.6/gdb/symfile.c:581
#4  0x56748 in symbol_add_stub (arg=0x35f408 "")
    at ../../gdb-4.6/gdb/solib.c:674
#5  0x2478 in catch_errors (func=0x56710 <print_insn+5536>, args=0x35f408 "", 
    errstring=0x567a0 "Error while reading shared library symbols:\n")
    at ../../gdb-4.6/gdb/main.c:367
#6  0x568dc in solib_add (arg_string=0x0, from_tty=1, target=0x0)
    at ../../gdb-4.6/gdb/solib.c:728
#7  0x57208 in sharedlibrary_command (args=0x0, from_tty=1)
    at ../../gdb-4.6/gdb/solib.c:1267
#8  0x3d90 in execute_command (p=0x14000d "", from_tty=1)
    at ../../gdb-4.6/gdb/main.c:915
#9  0x4014 in command_loop () at ../../gdb-4.6/gdb/main.c:976
#10 0x3af4 in main (argc=2, argv=0xf7ffe70c) at ../../gdb-4.6/gdb/main.c:853
-------------------------------------------------------------------------------

Here's a patch that appears (at first glance) to solve the problem, or at
least work around it:

-------------------------------------------------------------------------------
*** ORIG/partial-stab.h	Mon Aug 17 13:18:04 1992
--- partial-stab.h	Mon Aug 17 13:20:00 1992
***************
*** 493,499 ****
  #ifdef DBXREAD_ONLY
  	      /* Kludges for ELF/STABS with Sun ACC */
  	      last_function_name = namestring;
! 	      if (pst->textlow == 0)
  		pst->textlow = CUR_SYMBOL_VALUE;
  #if 0
  	      if (startup_file_end == 0)
--- 493,499 ----
  #ifdef DBXREAD_ONLY
  	      /* Kludges for ELF/STABS with Sun ACC */
  	      last_function_name = namestring;
! 	      if (pst && pst->textlow == 0)
  		pst->textlow = CUR_SYMBOL_VALUE;
  #if 0
  	      if (startup_file_end == 0)
***************
*** 515,521 ****
  #ifdef DBXREAD_ONLY
  	      /* Kludges for ELF/STABS with Sun ACC */
  	      last_function_name = namestring;
! 	      if (pst->textlow == 0)
  		pst->textlow = CUR_SYMBOL_VALUE;
  #if 0
  	      if (startup_file_end == 0)
--- 515,521 ----
  #ifdef DBXREAD_ONLY
  	      /* Kludges for ELF/STABS with Sun ACC */
  	      last_function_name = namestring;
! 	      if (pst && pst->textlow == 0)
  		pst->textlow = CUR_SYMBOL_VALUE;
  #if 0
  	      if (startup_file_end == 0)
------------------------------------------------------------------------------

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
David Wexelblat             | dwex@mtgzfs3.att.com  | Somebody get me a
AT&T Bell Laboratories      | ...!att!mtgzfs3!dwex  |    cheeseburger!
200 Laurel Ave - 4B-421     |                       |       
Middletown, NJ  07748       | (908) 957-5871        | --Steve Miller Band

Newsgroups: gnu.gdb.bug