From: Sergio Durigan Junior <sergiodj@redhat.com>
To: GDB Patches <gdb-patches@sourceware.org>
Cc: Sergio Durigan Junior <sergiodj@redhat.com>
Subject: [PATCH] Don't crash if dwarf_decode_macro_bytes's 'body' is NULL
Date: Tue, 14 May 2019 20:55:00 -0000 [thread overview]
Message-ID: <20190514205458.28796-1-sergiodj@redhat.com> (raw)
In-Reply-To: <871s124foc.fsf@tromey.com>
Hi,
Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1708192
https://bugzilla.redhat.com/show_bug.cgi?id=1708786
During the Fedora RPM build process, gdb-add-index is invoked to
extract the DWARF index from the binary, and GDB will segfault because
dwarf2read.c:parse_definition_macro's 'body' variable is NULL.
The underlying problem is that Fedora's rpm-build's "debugedit"
program will silently corrupt .debug_macro strings when a binary is
compiled with -g3. This is being taken care of by Mark Wielaard,
here:
https://bugzilla.redhat.com/show_bug.cgi?id=1708786
However, I still feel it's important to make GDB more resilient
against invalid DWARF input, so I'm proposing this rather simple patch
to catch the situation when "body == NULL" (i.e., it's probably been
corrupted) and issue a complaint. This is not a real fix to the
problem, of course, but at least GDB is able to finish without
segfaulting.
OK for master?
gdb/ChangeLog:
2019-05-14 Sergio Durigan Junior <sergiodj@redhat.com>
Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1708192
* dwarf2read.c (dwarf_decode_macro_bytes): Check whether 'body' is
NULL, and complain if that's the case.
---
gdb/ChangeLog | 6 ++++++
gdb/dwarf2read.c | 18 +++++++++++++++++-
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 19458ccc72..d64ed7df04 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2019-05-14 Sergio Durigan Junior <sergiodj@redhat.com>
+
+ Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1708192
+ * dwarf2read.c (parse_macro_definition): Check whether 'body' is
+ NULL, and complain/return if that's the case.
+
2019-05-12 Paul Naert <paul.naert@polymtl.ca>
* language.c (language_sniff_from_mangled_name): Fix "langauge"
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index b29c089606..63622ba76f 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -24609,7 +24609,23 @@ dwarf_decode_macro_bytes (struct dwarf2_cu *cu,
line == 0 ? _("zero") : _("non-zero"), line, body);
if (is_define)
- parse_macro_definition (current_file, line, body);
+ {
+ if (body != NULL)
+ parse_macro_definition (current_file, line, body);
+ else
+ {
+ /* Fedora's rpm-build's "debugedit" binary
+ corrupted .debug_macro sections.
+
+ For more info, see
+ https://bugzilla.redhat.com/show_bug.cgi?id=1708786 */
+ complaint (_("debug info gives %s invalid macro definition "
+ "without body (corrupted?) at line %d"),
+ at_commandline ? _("command-line")
+ : _("in-file"),
+ line == 0 ? _("zero") : _("non-zero"), line);
+ }
+ }
else
{
gdb_assert (macinfo_type == DW_MACRO_undef
--
2.17.2
next prev parent reply other threads:[~2019-05-14 20:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-10 21:04 [PATCH] Don't crash if parse_definition_macro's " Sergio Durigan Junior
2019-05-13 14:01 ` Tom Tromey
2019-05-14 20:54 ` Sergio Durigan Junior
2019-05-14 20:55 ` Sergio Durigan Junior [this message]
2019-05-14 22:10 ` [PATCH] Don't crash if dwarf_decode_macro_bytes's " 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=20190514205458.28796-1-sergiodj@redhat.com \
--to=sergiodj@redhat.com \
--cc=gdb-patches@sourceware.org \
/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