From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14542 invoked by alias); 21 Oct 2012 06:58:00 -0000 Received: (qmail 14533 invoked by uid 22791); 21 Oct 2012 06:57:58 -0000 X-SWARE-Spam-Status: No, hits=-4.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,KHOP_RCVD_TRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-wi0-f171.google.com (HELO mail-wi0-f171.google.com) (209.85.212.171) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 21 Oct 2012 06:57:53 +0000 Received: by mail-wi0-f171.google.com with SMTP id hj13so1152049wib.12 for ; Sat, 20 Oct 2012 23:57:52 -0700 (PDT) Received: by 10.180.94.102 with SMTP id db6mr13209683wib.20.1350802672139; Sat, 20 Oct 2012 23:57:52 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.141.218 with HTTP; Sat, 20 Oct 2012 23:57:31 -0700 (PDT) From: Josh Matthews Date: Sun, 21 Oct 2012 06:58:00 -0000 Message-ID: Subject: Fix immediate Darwin crash To: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 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/msg00377.txt.bz2 Attempting to debug any binary on Darwin currently triggers an immediate segfault. This patch corrects that. 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); }