This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix immediate Darwin crash


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);
> }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]