This is the mail archive of the
mailing list for the binutils project.
Re: [PATCH 3/5] remove deleted BFDs from the archive cache
On Fri, Aug 17, 2012 at 9:50 AM, Tom Tromey <firstname.lastname@example.org> wrote:
>>>>>> "HJ" == H J Lu <email@example.com> writes:
> HJ> I am not sure if we want to use bfd_zmalloc for all areltdata. We
> HJ> use bfd_ar_hdr_from_filesystem since we can't use member
> HJ> objalloc nor archive objalloc. In all other places, it is OK to
> HJ> use archive objalloc for areltdata.
> Aside from the latent bugs.
> HJ> Do you have a testcase to show there is a problem?
> barimba. valgrind --leak-check=full ./strip-new libutil.a
> ==30145== 696 bytes in 6 blocks are definitely lost in loss record 21 of 21
> ==30145== at 0x4A074CD: malloc (vg_replace_malloc.c:236)
> ==30145== by 0x432A58: bfd_zmalloc (libbfd.c:319)
> ==30145== by 0x428807: bfd_ar_hdr_from_filesystem (archive.c:1899)
> ==30145== by 0x428E4D: _bfd_write_archive_contents (archive.c:2131)
> ==30145== by 0x4342FE: bfd_close (opncls.c:714)
> ==30145== by 0x407991: copy_archive (objcopy.c:2208)
> ==30145== by 0x407E54: copy_file (objcopy.c:2318)
> ==30145== by 0x404699: main (objcopy.c:3168)
diff --git a/bfd/archive.c b/bfd/archive.c
index 2d67e1f..af6ba24 100644
@@ -2744,6 +2744,11 @@ _bfd_archive_close_and_cleanup (bfd *abfd)
htab_clear_slot (htab, slot);
+ /* If HTAB is NULL, free ARED allocated with bfd_zmalloc. */
+ free (ared);
However, it assumes that archive member from filesystem is
closed after archive. It won't be easy to get around it since
we can't get from archive member from filesystem to