From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25805 invoked by alias); 3 May 2011 16:28:31 -0000 Received: (qmail 25785 invoked by uid 22791); 3 May 2011 16:28:27 -0000 X-SWARE-Spam-Status: No, hits=-1.2 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,TW_BJ,TW_YM X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 03 May 2011 16:28:12 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id CF82D2BB08F for ; Tue, 3 May 2011 12:28:11 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id xJvdv1lMiDBA for ; Tue, 3 May 2011 12:28:11 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id A16A12BB08C for ; Tue, 3 May 2011 12:28:11 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id A90F8145615; Tue, 3 May 2011 09:28:07 -0700 (PDT) Date: Tue, 03 May 2011 16:28:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: Re: [RFA] elfread.c (elf_symtab_read): Stop memory leak. Message-ID: <20110503162807.GN2489@adacore.com> References: <4D729E84.3050401@vmware.com> <20110307111540.GB30306@adacore.com> <20110503155348.GA2528@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="uQr8t48UFsdbeI+V" Content-Disposition: inline In-Reply-To: <20110503155348.GA2528@adacore.com> User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-05/txt/msg00066.txt.bz2 --uQr8t48UFsdbeI+V Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 417 > > > 2011-03-05 Michael Snyder > > > > > > * 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. This is what I applied on HEAD and branch... -- Joel --uQr8t48UFsdbeI+V Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="elfread.diff" Content-length: 1543 commit 86a08e4d3dcf7c0ff728083ae2b02f83ef836a09 Author: Joel Brobecker Date: Tue May 3 17:55:06 2011 +0200 Revert "elfread.c (elf_symtab_read): Stop memory leak" It turns out that this change is not correct, and it causes a crash on sparc-solaris while trying to load ld.so. This is because the memory is actually still referenced after elf_symtab_read completes. gdb/ChangeLog: * elfread.c (elf_symtab_read): Revert the previous change that tried to stop a memory leak. diff --git a/gdb/elfread.c b/gdb/elfread.c index b9cfa13..f36c93b 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -257,7 +257,6 @@ elf_symtab_read (struct objfile *objfile, int type, char *filesymname = ""; struct dbx_symfile_info *dbx = objfile->deprecated_sym_stab_info; int stripped = (bfd_get_symcount (objfile->obfd) == 0); - struct cleanup *back_to = make_cleanup (null_cleanup, NULL); for (i = 0; i < number_of_symbols; i++) { @@ -482,7 +481,6 @@ elf_symtab_read (struct objfile *objfile, int type, + (sizeof (CORE_ADDR) * max_index)); sectinfo = (struct stab_section_info *) xmalloc (size); - make_cleanup (xfree, sectinfo); memset (sectinfo, 0, size); sectinfo->num_sections = max_index; if (filesym == NULL) @@ -591,7 +589,6 @@ elf_symtab_read (struct objfile *objfile, int type, } } } - do_cleanups (back_to); } /* Build minimal symbols named `function@got.plt' (see SYMBOL_GOT_PLT_SUFFIX) --uQr8t48UFsdbeI+V--