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


HJ> It breaks strip:
HJ> http://sourceware.org/bugzilla/show_bug.cgi?id=14475

Thanks

Here is a patch to fix the problem.

The bug is that bfd_ar_hdr_from_filesystem creates the areltdata on the
archive's objalloc.  But, since this data is attached to the member BFD,
it should really be created on the member's objalloc.

This also fixes another bug I noticed in bfd_ar_hdr_from_filesystem.
This code tries to free 'ared' in one case -- but that is wrong, as this
is not allocated using malloc.

I could see the bug before this patch using valgrind or -lmcheck.  After
the patch the problem is gone.

Ok?

Tom

2012-08-15  Tom Tromey  <tromey@redhat.com>

	PR binutils/14475:
	* archive.c (bfd_ar_hdr_from_filesystem): Allocate areltdata on
	'member' BFD.  Don't try to free 'ared'.

Index: archive.c
===================================================================
RCS file: /cvs/src/src/bfd/archive.c,v
retrieving revision 1.89
diff -u -r1.89 archive.c
--- archive.c	9 Aug 2012 06:25:52 -0000	1.89
+++ archive.c	15 Aug 2012 21:01:51 -0000
@@ -1896,7 +1896,7 @@
     }
 
   amt = sizeof (struct ar_hdr) + sizeof (struct areltdata);
-  ared = (struct areltdata *) bfd_zalloc (abfd, amt);
+  ared = (struct areltdata *) bfd_zalloc (member, amt);
   if (ared == NULL)
     return NULL;
   hdr = (struct ar_hdr *) (((char *) ared) + sizeof (struct areltdata));
@@ -1927,10 +1927,7 @@
   _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))
-    {
-      free (ared);
-      return NULL;
-    }
+    return NULL;
   memcpy (hdr->ar_fmag, ARFMAG, 2);
   ared->parsed_size = status.st_size;
   ared->arch_header = (char *) hdr;


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