From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29698 invoked by alias); 6 Jan 2014 17:12:47 -0000 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 Received: (qmail 29688 invoked by uid 89); 6 Jan 2014 17:12:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-vc0-f179.google.com Received: from mail-vc0-f179.google.com (HELO mail-vc0-f179.google.com) (209.85.220.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 06 Jan 2014 17:12:45 +0000 Received: by mail-vc0-f179.google.com with SMTP id hq11so1660019vcb.10 for ; Mon, 06 Jan 2014 09:12:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=FGiV3ZIz1G0wdyS0AsfZsE+WD2NdoA0TrS4rYI6bWFI=; b=XmWGTC7iwt1mgAeeAlqr8w67beHQfikRzKUC2CJjU21f+R8G4FY5f6EJaDKeCP4HcN vyWJ6rvCUteim/j0TkHaQrIKz5a8lVeE/38Z7YApC9G+aBXXLPMmcfccoFPN1kEGuQ5k iRbPHJ9ow5vlEoLQqVuEJGaV86sOu8+qkoqPjNtb3wRgMb08/E8U4ZfEwDSdUMesKYEJ aaRadLSY1bF3NqCj/m8PNkwIIOtzux+hL/dSuGpJrBXB47vLrPqoS4JJUG8m2yNa9QKY yp6xNK2c8GLIzbgUGVVcqi20H8dbp+lWzkOSp0mJP2/AguaZihuHVmE1sGv59Ezs9+Js 2wUw== X-Gm-Message-State: ALoCoQm2agGOxJ+iLqbtNhFIfF24o+CHzJjhci7UADADWHDpDgmsAjFyaYO15dDBiRl6WX3t5GibcEWw9bJ/X6/wKLXID3HRrlci7dA43g/vb1RYRdbEiqIIWq98glTu5bmxvi37ZgPvQENiMpTc79HTn0nJoqCb9FW2lSKBlUohLtIeTC4aWalSL3osSrtJR/y0BBIdBOw8dT1TAMJfU4PU4gnnB7+LaA== MIME-Version: 1.0 X-Received: by 10.52.26.77 with SMTP id j13mr3949769vdg.33.1389028363710; Mon, 06 Jan 2014 09:12:43 -0800 (PST) Received: by 10.52.248.65 with HTTP; Mon, 6 Jan 2014 09:12:43 -0800 (PST) In-Reply-To: <52CA8A7F.7090907@mentor.com> References: <52C8358B.7080101@mentor.com> <52C97EC0.3080807@mentor.com> <87k3edseia.fsf@fleche.redhat.com> <52CA8A7F.7090907@mentor.com> Date: Mon, 06 Jan 2014 17:12:00 -0000 Message-ID: Subject: Re: [PATCH] Remove gdb_bfd_stash_filename to fix crash with fix of binutils/11983 From: Doug Evans To: Hui Zhu Cc: Tom Tromey , Sergio Durigan Junior , gdb-patches ml , Edjunior Barbosa Machado , Nick Clifton Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-01/txt/msg00069.txt.bz2 On Mon, Jan 6, 2014 at 2:50 AM, Hui Zhu wrote: > On 01/06/14 16:25, Tom Tromey wrote: >>>>>>> >>>>>>> "Hui" == Hui Zhu writes: >> >> >> Hui> Thanks. Post a new version. >> >> Thanks Hui. This is definitely the direction I think the code should >> go. >> >> Hui> --- a/gdb/symfile-mem.c >> Hui> +++ b/gdb/symfile-mem.c >> Hui> @@ -104,11 +104,7 @@ symbol_file_add_from_memory (struct bfd >> Hui> if (name == NULL) >> Hui> nbfd-> filename = "shared object read from target memory"; >> Hui> else >> Hui> - { >> Hui> - nbfd->filename = name; >> Hui> - gdb_bfd_stash_filename (nbfd); >> Hui> - xfree (name); >> Hui> - } >> Hui> + nbfd->filename = name; >> Hui> cleanup = make_cleanup_bfd_unref (nbfd); >> >> In this hunk there are two things to note. >> >> First, there is an earlier assignment to filename (in the context above) >> that should use xstrdup. >> >> Second, the new assignment really ought to free the old nbfd->filename >> first. > > > I changed this part to: > xfree (bfd_get_filename (nbfd)); > if (name == NULL) > nbfd->filename = xstrdup ("shared object read from target memory"); > else > nbfd->filename = name; I would prefer a new bfd routine to set the file name. Then *it* is responsible for freeing the old name. Any reason to not go that route? > --- a/gdb/symfile-mem.c > +++ b/gdb/symfile-mem.c > @@ -101,14 +101,11 @@ symbol_file_add_from_memory (struct bfd > error (_("Failed to read a valid object file image from memory.")); > gdb_bfd_ref (nbfd); > + xfree (bfd_get_filename (nbfd)); This line still screams of excessive chumminess with bfd. > if (name == NULL) > - nbfd->filename = "shared object read from target memory"; > + nbfd->filename = xstrdup ("shared object read from target memory"); > else > - { > > - nbfd->filename = name; > - gdb_bfd_stash_filename (nbfd); > - xfree (name); > - } > + nbfd->filename = name; > cleanup = make_cleanup_bfd_unref (nbfd); >