* Fix immediate Darwin crash
@ 2012-10-21 6:58 Josh Matthews
2012-10-22 8:53 ` Tristan Gingold
0 siblings, 1 reply; 2+ messages in thread
From: Josh Matthews @ 2012-10-21 6:58 UTC (permalink / raw)
To: gdb-patches
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);
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Fix immediate Darwin crash
2012-10-21 6:58 Fix immediate Darwin crash Josh Matthews
@ 2012-10-22 8:53 ` Tristan Gingold
0 siblings, 0 replies; 2+ messages in thread
From: Tristan Gingold @ 2012-10-22 8:53 UTC (permalink / raw)
To: Josh Matthews; +Cc: gdb-patches
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 <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);
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-10-22 8:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-21 6:58 Fix immediate Darwin crash Josh Matthews
2012-10-22 8:53 ` Tristan Gingold
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox