This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Fix immediate Darwin crash
- From: Josh Matthews <josh at joshmatthews dot net>
- To: gdb-patches at sourceware dot org
- Date: Sun, 21 Oct 2012 02:57:31 -0400
- Subject: Fix immediate Darwin crash
Attempting to debug any binary on Darwin currently triggers an
immediate segfault. This patch corrects that.
Cheers,
Josh
2012-10-21 Josh Matthews <josh@joshmatthews.net>
* 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);
}