From: Simon Marchi <simon.marchi@ericsson.com>
To: Tom Tromey <tom@tromey.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Check return value of bfd_init
Date: Thu, 25 Oct 2018 15:25:00 -0000 [thread overview]
Message-ID: <e66634a4-ab1c-f85a-6067-98d9bda4cab1@ericsson.com> (raw)
In-Reply-To: <20181025150340.28844-1-tom@tromey.com>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 2445 bytes --]
On 2018-10-25 11:03 a.m., Tom Tromey wrote:
> Alan recently added a way for BFD library users to check whether they
> were in fact loading a compatible version of BFD:
>
> https://sourceware.org/ml/binutils/2018-10/msg00198.html
>
> It seemed reasonable to me that gdb should do this check as well, in
> case someone is dynamically linking against BFD. Tested by rebuilding
> and then starting the resulting gdb.
>
> gdb/ChangeLog
> 2018-10-25 Tom Tromey <tom@tromey.com>
>
> * main.c (captured_main_1): Check return value of bfd_init.
> ---
> gdb/ChangeLog | 4 ++++
> gdb/main.c | 3 ++-
> 2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index 61dc039d4fe..a90c2978185 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,3 +1,7 @@
> +2018-10-25 Tom Tromey <tom@tromey.com>
> +
> + * main.c (captured_main_1): Check return value of bfd_init.
> +
> 2018-10-25 Andrew Burgess <andrew.burgess@embecosm.com>
>
> * python/py-function.c (convert_values_to_python): Return
> diff --git a/gdb/main.c b/gdb/main.c
> index 8709357e924..96def3080eb 100644
> --- a/gdb/main.c
> +++ b/gdb/main.c
> @@ -506,7 +506,8 @@ captured_main_1 (struct captured_main_args *context)
> textdomain (PACKAGE);
> #endif
>
> - bfd_init ();
> + if (bfd_init () != BFD_INIT_MAGIC)
> + error (_("fatal error: libbfd ABI mismatch"));
> notice_open_fds ();
>
> saved_command_line = (char *) xstrdup ("");
>
It doesn't work to call error that early. Try to reverse the condition and start
gdb, you'll get:
$ ./gdb
ASAN:SIGSEGV
=================================================================
==12947==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000090 (pc 0x0000013a7a2f bp 0x7ffcbd048510 sp 0x7ffcbd048460 T0)
#0 0x13a7a2e in gdb_main(captured_main_args*) /home/emaisin/src/binutils-gdb/gdb/main.c:1194
#1 0xb27098 in main /home/emaisin/src/binutils-gdb/gdb/gdb.c:32
#2 0x7ff24431482f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
#3 0xb26ef8 in _start (/home/emaisin/build/binutils-gdb/gdb/gdb+0xb26ef8)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/emaisin/src/binutils-gdb/gdb/main.c:1194 gdb_main(captured_main_args*)
==12947==ABORTING
So fprintf to stderr and exit instead?
Simon
\x16º&Öéj×!zÊÞ¶êç×|ëb²Ö«r\x18\x1dnr\x17¬
next prev parent reply other threads:[~2018-10-25 15:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-25 15:03 Tom Tromey
2018-10-25 15:25 ` Simon Marchi [this message]
[not found] ` <87efcehwlx.fsf@tromey.com>
2018-10-26 15:41 ` Tom Tromey
2018-10-26 18:31 ` Simon Marchi
2018-10-26 19:48 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e66634a4-ab1c-f85a-6067-98d9bda4cab1@ericsson.com \
--to=simon.marchi@ericsson.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox