This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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: [PATCH 3/5] remove deleted BFDs from the archive cache


On Fri, Aug 17, 2012 at 10:18:25AM +0930, Alan Modra wrote:
> On Thu, Aug 16, 2012 at 11:02:18AM -0600, Tom Tromey wrote:
> > Another possible fix for this bug would be to allocate the areltdata
> > using malloc.  That way it would be immune to the objalloc_free call.
> > This would require a few more tweaks, like properly freeing it in
> > _bfd_delete_bfd, etc.
> > 
> > I'm happy to make and test this change if you think it would be better.
> 
> Yes, I do think that would be better.  bfd_free_cached_info is called
> only in one place, and the whole point of the call is as the comment
> says
> 	  /* Now ask the BFD to free up any cached information, so we
> 	     don't fill all of memory with symbol tables.  */
> 
> If you don't free the bfd memory there isn't much point in having
> bfd_free_cached_info!
> 
> > 	* opncls.c (_bfd_delete_bfd): Check to see if section htab is
> > 	already freed.
> 
> This part can be committed now if you like.

And in the interests of having a binutils tree that work, I'm
committing this fix now.

	PR binutils/14475:
	* archive.c (bfd_ar_hdr_from_filesystem): Revert last change.
	Instead malloc areltdata.

Index: bfd/archive.c
===================================================================
RCS file: /cvs/src/src/bfd/archive.c,v
retrieving revision 1.90
diff -u -p -r1.90 archive.c
--- bfd/archive.c	16 Aug 2012 14:24:44 -0000	1.90
+++ bfd/archive.c	17 Aug 2012 01:02:13 -0000
@@ -1896,7 +1896,7 @@ bfd_ar_hdr_from_filesystem (bfd *abfd, c
     }
 
   amt = sizeof (struct ar_hdr) + sizeof (struct areltdata);
-  ared = (struct areltdata *) bfd_zalloc (member, amt);
+  ared = (struct areltdata *) bfd_zmalloc (amt);
   if (ared == NULL)
     return NULL;
   hdr = (struct ar_hdr *) (((char *) ared) + sizeof (struct areltdata));
@@ -1927,7 +1927,10 @@ bfd_ar_hdr_from_filesystem (bfd *abfd, c
   _bfd_ar_spacepad (hdr->ar_mode, sizeof (hdr->ar_mode), "%-8lo",
 		    status.st_mode);
   if (!_bfd_ar_sizepad (hdr->ar_size, sizeof (hdr->ar_size), status.st_size))
-    return NULL;
+    {
+      free (ared);
+      return NULL;
+    }
   memcpy (hdr->ar_fmag, ARFMAG, 2);
   ared->parsed_size = status.st_size;
   ared->arch_header = (char *) hdr;

-- 
Alan Modra
Australia Development Lab, IBM


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