🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gdb.bug
Article #585

gdb-4.7 dumps on nil textsection ptr (gcc2.3.3/solaris2/shared object)

#585
From: Henry A Worth
Date: Fri, 08 Jan 1993 00:07
76 lines
3446 bytes
   gdb dumped (seg. excep) while trying to attach to a running process
(shared objects in use). The object included a shared object without a
text section which resulted in a nil ptr in the function symbol_add_stub()
in the gdb source file solib.c. gdb-4.7 and the objects were all compiled
with gcc-2.3.3 running under Solaris2.0.


gdb of gdb-4.7's core dump (same error also occurs in earlier gdb's):

     (gdb) core core
     Core was generated by `gdb-4.7 sm'.
     Program terminated with signal 11, Segmentation fault.
     #0  0x67028 in symbol_add_stub (arg=0x2f5208 "") at solib.c:674
     674       so -> objfile = symbol_file_add (so -> so_name, so -> from_tty,

the full statement & function:
 
/* A small stub to get us past the arg-passing pinhole of catch_errors.  */
 
static int
symbol_add_stub (arg)
     char *arg;
{
  register struct so_list *so = (struct so_list *) arg; /* catch_errs bogon */
 
  so -> objfile = symbol_file_add (so -> so_name, so -> from_tty,
                                   (unsigned int) so -> textsection -> addr,
note>>                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^
                                   0, 0, 0);
  return (1);
}

returning to gdb:
     
     (gdb) p so
     $1 = (struct so_list *) 0x2f5208
     (gdb) p *so
     $2 = {next = 0x0, lm = {l_addr = 4014080000, 
         l_name = 0xef7fa2e4<Address 0xef7fa2e4 out of bounds>, 
         l_ld = 0xef434494, 
         l_next = 0xef7fa3dc, l_prev = 0xef7fa254}, lmaddr = 0xef7fa31c, 
       lmend = 4014163092, 
       so_name = {"/xxxxx/xxxxx/xxxxx/xxxxx/xxxxx/xxx.so", 

The source file (name changed to protect the guilty) contains a global 
date table and no functions (same error also occurs if it is a .sa  file). 
It was compiled with gcc-2.3.3 with the options: -g -O2 -fno-inline -fpic.

       '\000' <repeats 205 times>}, symbols_loaded = 0 '\000', from_tty = 0 
       '\000', 
       so_bfd = 0x321108, objfile = 0x0, sections = 0x25a908, 
       sections_end = 0x25a928, textsection = 0x0}
note>>                          ^^^^^^^^^^^^^^^^^
     
     (gdb) bt
     #0  0x67028 in symbol_add_stub (arg=0x2f5208 "") at solib.c:674
     #1  0x213c8 in catch_errors (func=0x67008 <_initialize_exec+2120>, 
         args=0x2f5208 "", 
         errstring=0x140140 "Error while reading shared library symbols:\n")
         at main.c:370
     #2  0x67170 in solib_add (arg_string=0x0, from_tty=1, target=0x0)
         at solib.c:728
     #3  0x53904 in attach_command (args=0x18900f "6633", from_tty=1)
         at infcmd.c:1083
     #4  0x226c4 in execute_command (p=0x18900f "6633", from_tty=1) at 
         main.c:931
     #5  0x22928 in command_loop () at main.c:990
     #6  0x22410 in main (argc=2, argv=0xeffff794) at main.c:857


fix(?)/workaround:

Added check of so->textsection, if nil then pass a nil to symbol_file_add() 
for the third argument.
    
 
Technical Details
Message-ID: <9301080007.AA14662@zeus.ras.amdahl.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ras.amdahl.COM!haw30

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gdb.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ras.amdahl.COM!haw30
From: haw30@ras.amdahl.COM (Henry A Worth)
Subject: gdb-4.7 dumps on nil textsection ptr (gcc2.3.3/solaris2/shared object)
Message-ID: <9301080007.AA14662@zeus.ras.amdahl.com>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Fri, 8 Jan 1993 00:07:14 GMT
Approved: bug-gdb@prep.ai.mit.edu
Lines: 77