From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14994 invoked by alias); 19 Nov 2010 22:49:11 -0000 Received: (qmail 14986 invoked by uid 22791); 19 Nov 2010 22:49:10 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 19 Nov 2010 22:49:04 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oAJMn2T9009172 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 19 Nov 2010 17:49:03 -0500 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oAJMmwnH022266 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 19 Nov 2010 17:49:02 -0500 Received: from host0.dyn.jankratochvil.net (localhost.localdomain [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id oAJMmups005797; Fri, 19 Nov 2010 23:48:56 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id oAJMmtj8005796; Fri, 19 Nov 2010 23:48:55 +0100 Date: Fri, 19 Nov 2010 22:49:00 -0000 From: Jan Kratochvil To: Tom Tromey Cc: gdb-patches@sourceware.org, Doug Evans Subject: Re: [patch] Fix ELF stale reference Message-ID: <20101119224854.GA4675@host0.dyn.jankratochvil.net> References: <20100908185837.GA24606@host1.dyn.jankratochvil.net> <20100909090511.GA937@host1.dyn.jankratochvil.net> <20100909145615.GA5771@host1.dyn.jankratochvil.net> <20101014160653.GA24333@host1.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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: 2010-11/txt/msg00274.txt.bz2 On Thu, 14 Oct 2010 19:46:13 +0200, Tom Tromey wrote: > >>>>> "Jan" == Jan Kratochvil writes: > > Jan> OK to check-in? Or some bfd/ API improvement should be made? > > I think this is probably the cleanest fix. Checked in. > However, libbfd.h does say right at the top that it shouldn't be used. > > I guess we could ask for advice on the binutils list. This part has been fixed recently in binutils (as you forwarded me): http://sourceware.org/ml/binutils/2010-10/msg00413.html So no new libbfd.h include is now needed in GDB. Regarding the introduced memory leak it seems to be fixable but I have only filed GDB PR for it now: http://sourceware.org/bugzilla/show_bug.cgi?id=12243 Thanks, Jan http://sourceware.org/ml/gdb-cvs/2010-11/msg00094.html --- src/gdb/ChangeLog 2010/11/19 18:10:43 1.12319 +++ src/gdb/ChangeLog 2010/11/19 22:30:44 1.12320 @@ -1,4 +1,10 @@ 2010-11-19 Jan Kratochvil + + Fix stale memory references. + * elfread.c (elf_symfile_read): Replace xmalloc by bfd_alloc, drop + xfree, new comment. + +2010-11-19 Jan Kratochvil Tom Tromey * Makefile.in (.y.c): Directly create $@ from YLWRAP. --- src/gdb/elfread.c 2010/10/01 20:26:11 1.99 +++ src/gdb/elfread.c 2010/11/19 22:30:47 1.100 @@ -790,8 +790,14 @@ if (storage_needed > 0) { - dyn_symbol_table = (asymbol **) xmalloc (storage_needed); - make_cleanup (xfree, dyn_symbol_table); + /* Memory gets permanently referenced from ABFD after + bfd_get_synthetic_symtab so it must not get freed before ABFD gets. + It happens only in the case when elf_slurp_reloc_table sees + asection->relocation NULL. Determining which section is asection is + done by _bfd_elf_get_synthetic_symtab which is all a bfd + implementation detail, though. */ + + dyn_symbol_table = bfd_alloc (abfd, storage_needed); dynsymcount = bfd_canonicalize_dynamic_symtab (objfile->obfd, dyn_symbol_table);