From: Sergio Durigan Junior <sergiodj@redhat.com>
To: Tom Tromey <tom@tromey.com>
Cc: GDB Patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Don't crash if parse_definition_macro's 'body' is NULL
Date: Tue, 14 May 2019 20:54:00 -0000 [thread overview]
Message-ID: <8736lg69kh.fsf@redhat.com> (raw)
In-Reply-To: <871s124foc.fsf@tromey.com> (Tom Tromey's message of "Mon, 13 May 2019 08:01:07 -0600")
On Monday, May 13 2019, Tom Tromey wrote:
>>>>>> "Sergio" == Sergio Durigan Junior <sergiodj@redhat.com> writes:
>
> Sergio> This very simple patch is just a safeguard against this scenario; it
> Sergio> is not a fix for the problem (which actually happens on "debugedit",
> Sergio> and which Mark Wielaard is already working on), but at least it makes
> Sergio> GDB not crash on invalid DWARF, which is a plus IMO.
>
> I don't really get why read_direct_string (and the other functions like
> it) returns NULL when it sees an empty string. How is something like
> "#define X" represented such that this doesn't return NULL?
Thanks for the review.
We've already talked on IRC, but I'll just mention it here as well:
When read_indirect_string_at_offset is called (from
dwarf_decode_macro_bytes), you see this code:
...
if (sect->buffer[str_offset] == '\0')
return NULL;
...
You were wondering why a case like "#define X" didn't trigger this bug,
because NULL should be returned. However, as I found, in this scenario
sect->buffer will contain "X ". I.e., it will always contain the
macro's name + its (optional) value. What we're actually dealing with
here, in debugedit's case, is the corruption of the .debug_macro
section, which renders the define useless.
A more in-depth analysis by Keith can be found here:
https://bugzilla.redhat.com/show_bug.cgi?id=1684303#c2
> Other complaints in the caller of parse_macro_definition provide a bit
> more context, like the macro name, source file, and line number:
>
> complaint (_("debug info gives %s macro %s with %s line %d: %s"),
> at_commandline ? _("command-line") : _("in-file"),
> is_define ? _("definition") : _("undefinition"),
> line == 0 ? _("zero") : _("non-zero"), line, body);
>
> ... so maybe the new complaint could as well.
I did my best and updated the complaint to contain more info. I'm
afraid the only extra bit I was able to add was the line number, which,
by my tests, will not be entirely correct (perhaps due to the corruption
itself). I'll send the patch soon.
Thanks,
--
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/
next prev parent reply other threads:[~2019-05-14 20:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-10 21:04 Sergio Durigan Junior
2019-05-13 14:01 ` Tom Tromey
2019-05-14 20:54 ` Sergio Durigan Junior [this message]
2019-05-14 20:55 ` [PATCH] Don't crash if dwarf_decode_macro_bytes's " Sergio Durigan Junior
2019-05-14 22:10 ` Tom Tromey
2019-05-14 23:36 ` Sergio Durigan Junior
2019-05-15 1:38 ` Tom Tromey
2019-05-15 8:49 ` Andreas Schwab
2019-05-15 13:53 ` Tom Tromey
2019-05-15 13:59 ` Sergio Durigan Junior
2019-05-29 14:43 ` [PATCH] Don't crash is dwarf_decode_macro_bytes's 'body' is NULL, even when '!is_define' Sergio Durigan Junior
2019-05-29 15:55 ` Tom Tromey
2019-05-29 20:16 ` Sergio Durigan Junior
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=8736lg69kh.fsf@redhat.com \
--to=sergiodj@redhat.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