This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Solibs and objfile BFD ownership


On Tue, Aug 4, 2009 at 11:47 AM, Paul Pluzhnikov<ppluzhnikov@google.com> wrote:

> So committed. Thanks,

I seem to have hit a rough patch with my patches :-(

The BFD refcounting patch from 2009-08-04 causes GDB to crash when I attach
to a process with many solibs, then (while GDB is reading solib symbols)
change my mind about attaching and hit Control-C, then 'run'.

This is happening because in symbol_add_stub refcount may not be set:

   so->objfile = symbol_file_add_from_bfd (so->abfd, flags, sap, OBJF_SHARED);

---> QUIT could be executed deep inside symbol_file_add_from_bfd, and
---> bfd_userdata below is never set.

   p_refcount = xmalloc (sizeof (*p_refcount));
   *p_refcount = 2;  /* Both solib and objfile refer to this abfd.  */
   bfd_usrdata (so->abfd) = p_refcount;

Later, we re-enter symbol_add_stub, and this:

   ALL_OBJFILES (so->objfile)
     {
       if (strcmp (so->objfile->name, so->so_name) == 0)
         return;

re-connects the so with the objfile, but never sets the bfd_usrdata.

Later still (during execution of 'run'), we go through clear_solib and
objfile_purge_solibs, and the latter crashes trying to bfd_close the abfd
which has already been bfd_close()d by the former.

Here is a proposed patch. Tested on Linux/x86_64 with no new failures.

Thanks,
-- 
Paul Pluzhnikov

2009-08-17  Paul Pluzhnikov  <ppluzhnikov@google.com>

	* solib.c (set_ref_count): New function.
	(symbol_add_stub): Call it.

Attachment: gdb-bfd-ownership-20090817.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]