From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4616 invoked by alias); 22 Oct 2012 08:53:33 -0000 Received: (qmail 4608 invoked by uid 22791); 22 Oct 2012 08:53:32 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 22 Oct 2012 08:53:28 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 35276290B2A; Mon, 22 Oct 2012 10:53:28 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lYhth11ntqqh; Mon, 22 Oct 2012 10:53:28 +0200 (CEST) Received: from ulanbator.act-europe.fr (ulanbator.act-europe.fr [10.10.1.67]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 21564290B26; Mon, 22 Oct 2012 10:53:27 +0200 (CEST) Subject: Re: Fix immediate Darwin crash Mime-Version: 1.0 (Apple Message framework v1278) Content-Type: text/plain; charset=iso-8859-1 From: Tristan Gingold In-Reply-To: Date: Mon, 22 Oct 2012 08:53:00 -0000 Cc: gdb-patches@sourceware.org Content-Transfer-Encoding: 7bit Message-Id: <09F586D0-BE66-420C-B7FD-FEE4E57522D4@adacore.com> References: To: Josh Matthews 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: 2012-10/txt/msg00382.txt.bz2 On Oct 21, 2012, at 8:57 AM, Josh Matthews wrote: > Attempting to debug any binary on Darwin currently triggers an > immediate segfault. This patch corrects that. Josh, this must be submitted on the binutils mailing list. Tristan. > > Cheers, > Josh > > 2012-10-21 Josh Matthews > > * mach-o.c (bfd_mach_o_close_and_cleanup): Clear tdata > pointer to avoid incorrect archive data deletion. > * archive.c (_bfd_archive_close_and_cleanup): Avoid > accessing archive cache data when tdata is null. > > diff --git a/bfd/archive.c b/bfd/archive.c > index 8e8fd2d..3771272 100644 > --- a/bfd/archive.c > +++ b/bfd/archive.c > @@ -2715,7 +2715,8 @@ _bfd_archive_close_and_cleanup (bfd *abfd) > { > bfd *nbfd; > bfd *next; > - htab_t htab; > + struct artdata *ardata; > + htab_t htab = NULL; > > /* Close nested archives (if this bfd is a thin archive). */ > for (nbfd = abfd->nested_archives; nbfd; nbfd = next) > @@ -2724,7 +2725,11 @@ _bfd_archive_close_and_cleanup (bfd *abfd) > bfd_close (nbfd); > } > > - htab = bfd_ardata (abfd)->cache; > + ardata = bfd_ardata (abfd); > + if (ardata) > + { > + htab = ardata->cache; > + } > if (htab) > { > htab_traverse_noresize (htab, archive_close_worker, NULL); > diff --git a/bfd/mach-o.c b/bfd/mach-o.c > index 0379f4f..7c44c5a 100644 > --- a/bfd/mach-o.c > +++ b/bfd/mach-o.c > @@ -4863,6 +4863,10 @@ bfd_mach_o_close_and_cleanup (bfd *abfd) > free (dsym_filename); > } > } > + else if (bfd_get_format (abfd) == bfd_archive) > + { > + abfd->tdata.mach_o_fat_data = NULL; > + } > > return _bfd_generic_close_and_cleanup (abfd); > }