This is the mail archive of the gdb-patches@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: [RFA] elfread.c (elf_symtab_read): Stop memory leak.


> > 2011-03-05  Michael Snyder  <msnyder@vmware.com>
> > 
> > 	* elfread.c (elf_symtab_read): Stop memory leak.
> 
> I think that's OK.  A little more nervous than usual, as I had
> to look through a fair bit of code.  But you did run this change
> past the testsuite, right?

I'm going to revert this patch, because I don't think it's right.
It's causing GDB to crash while loading symbols from ld.so on
sparc-solaris. Reviewing the patch again, I can't understand what
I was thinking when I reviewed it, because the data is referenced
by the objfile, thusly:

  struct dbx_symfile_info *dbx = objfile->deprecated_sym_stab_info;
  [...]
          if (sectinfo != NULL)
            {
              sectinfo->next = dbx->stab_section_info;
              dbx->stab_section_info = sectinfo;
              sectinfo = NULL;
            }

There may very well be a memory leak, but it's a lot less contained
than Michael probably thought. I don't know the code well enough
to really be sure how we'd be leaking, and risk a fix.  Perhaps
the sectinfo list should be released in:

    /* Perform any local cleanups required when we are done with a particular
       objfile.  I.E, we are in the process of discarding all symbol information
       for an objfile, freeing up all memory held for it, and unlinking the
       objfile struct from the global list of known objfiles.  */
    
    static void
    elf_symfile_finish (struct objfile *objfile)
    {
      if (objfile->deprecated_sym_stab_info != NULL)
        {
          xfree (objfile->deprecated_sym_stab_info);
        }
    
      dwarf2_free_objfile (objfile);
    }

A call to free_elfinfo before the call to xfree might do:

    /* This cleans up the objfile's deprecated_sym_stab_info pointer, and
       the chain of stab_section_info's, that might be dangling from
       it.  */
    
    static void
    free_elfinfo (void *objp)
    {

-- 
Joel


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