This is the mail archive of the
mailing list for the binutils project.
Re: [PATCH] Remove gdb_bfd_stash_filename to fix crash with fix of binutils/11983
- From: Tom Tromey <tromey at redhat dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: Doug Evans <dje at google dot com>, Hui Zhu <hui_zhu at mentor dot com>, Sergio Durigan Junior <sergiodj at redhat dot com>, gdb-patches ml <gdb-patches at sourceware dot org>, Edjunior Barbosa Machado <emachado at linux dot vnet dot ibm dot com>, Nick Clifton <nickc at redhat dot com>, Binutils Development <binutils at sourceware dot org>
- Date: Tue, 07 Jan 2014 10:40:54 -0700
- Subject: Re: [PATCH] Remove gdb_bfd_stash_filename to fix crash with fix of binutils/11983
- Authentication-results: sourceware.org; auth=none
- References: <52C8358B dot 7080101 at mentor dot com> <m3mwja5v01 dot fsf at redhat dot com> <52C97EC0 dot 3080807 at mentor dot com> <87k3edseia dot fsf at fleche dot redhat dot com> <52CA8A7F dot 7090907 at mentor dot com> <CADPb22QzyGuTEERURKao991F4jttvMqSrxodQz3JU2MLNgQ=tg at mail dot gmail dot com> <878uuslt1j dot fsf at fleche dot redhat dot com> <52CBF47C dot 9010002 at redhat dot com>
>>>>> "Pedro" == Pedro Alves <firstname.lastname@example.org> writes:
Pedro> gdb has been confused and went in circles, with bfd's filename
Pedro> ownership. In some places, it ended up xmalloc/xstrdup'ing the
Pedro> filename instead of allocating it in the bfd's memory.
Pedro> That resulted in the invention of gdb_bfd_stash_filename
Pedro> as a workaround.
Yeah, in retrospect I should have tried to fix up BFD at that time.
Pedro> I think it'd be better to allocate the filename
Pedro> in the bfd's memory, like it used to be.
I agree. I think your patch is better due to keeping the same
error-handling approach as the rest of BFD.
If you don't mind I think it would be good -- and easy -- to also
implement Doug's suggestion, say a "bfd_set_filename" macro.
Pedro> +/* A wrapper for bfd_strdup that never returns NULL. */
Pedro> +char *gdb_bfd_strdup (bfd *abfd, const char *str);
This can be marked ATTRIBUTE_RETURNS_NONNULL.