From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17561 invoked by alias); 17 Aug 2012 16:59:49 -0000 Received: (qmail 17548 invoked by uid 22791); 17 Aug 2012 16:59:47 -0000 X-SWARE-Spam-Status: No, hits=-3.8 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-vb0-f41.google.com (HELO mail-vb0-f41.google.com) (209.85.212.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 17 Aug 2012 16:59:32 +0000 Received: by vbkv13 with SMTP id v13so4045571vbk.0 for ; Fri, 17 Aug 2012 09:59:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.58.65.10 with SMTP id t10mr2094879ves.48.1345222771263; Fri, 17 Aug 2012 09:59:31 -0700 (PDT) Received: by 10.58.234.39 with HTTP; Fri, 17 Aug 2012 09:59:31 -0700 (PDT) In-Reply-To: <871uj5laxs.fsf@fleche.redhat.com> References: <20120803160934.GE4430@bubble.grove.modra.org> <87hasdgv0h.fsf@fleche.redhat.com> <20120809101540.GA30412@bubble.grove.modra.org> <87wr0zsw9h.fsf@fleche.redhat.com> <20120816135258.GN3947@bubble.grove.modra.org> <87393mpy79.fsf@fleche.redhat.com> <20120817004825.GP3947@bubble.grove.modra.org> <20120817011722.GR3947@bubble.grove.modra.org> <87ipchlcua.fsf@fleche.redhat.com> <871uj5laxs.fsf@fleche.redhat.com> Date: Fri, 17 Aug 2012 17:11:00 -0000 Message-ID: Subject: Re: [PATCH 3/5] remove deleted BFDs from the archive cache From: "H.J. Lu" To: Tom Tromey Cc: Binutils Development Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2012-08/txt/msg00348.txt.bz2 On Fri, Aug 17, 2012 at 9:50 AM, Tom Tromey wrote: >>>>>> "HJ" == H J Lu 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) > From http://sourceware.org/ml/binutils/2012-08/msg00309.html diff --git a/bfd/archive.c b/bfd/archive.c index 2d67e1f..af6ba24 100644 --- a/bfd/archive.c +++ b/bfd/archive.c @@ -2744,6 +2744,11 @@ _bfd_archive_close_and_cleanup (bfd *abfd) htab_clear_slot (htab, slot); } } + else + { + /* If HTAB is NULL, free ARED allocated with bfd_zmalloc. */ + free (ared); + } } return TRUE; } 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 archive. -- H.J.