|
|
6240d7 |
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
6240d7 |
From: Sergio Durigan Junior <sergiodj@redhat.com>
|
|
|
6240d7 |
Date: Fri, 10 May 2019 16:57:26 -0400
|
|
|
6240d7 |
Subject: gdb-rhbz1708192-parse_macro_definition-crash.patch
|
|
|
6240d7 |
|
|
|
6240d7 |
;; "Fix" segfault that happens on parse_macro_definition because
|
|
|
6240d7 |
;; debugedit corrupts the .debug_macro section.
|
|
|
6240d7 |
;; Sergio Durigan Junior, RH BZ 1708192.
|
|
|
6240d7 |
|
|
|
6240d7 |
Don't crash if dwarf_decode_macro_bytes's 'body' is NULL
|
|
|
6240d7 |
|
|
|
6240d7 |
Hi,
|
|
|
6240d7 |
|
|
|
6240d7 |
Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1708192
|
|
|
6240d7 |
https://bugzilla.redhat.com/show_bug.cgi?id=1708786
|
|
|
6240d7 |
|
|
|
6240d7 |
During the Fedora RPM build process, gdb-add-index is invoked to
|
|
|
6240d7 |
extract the DWARF index from the binary, and GDB will segfault because
|
|
|
6240d7 |
dwarf2read.c:parse_definition_macro's 'body' variable is NULL.
|
|
|
6240d7 |
|
|
|
6240d7 |
The underlying problem is that Fedora's rpm-build's "debugedit"
|
|
|
6240d7 |
program will silently corrupt .debug_macro strings when a binary is
|
|
|
6240d7 |
compiled with -g3. This is being taken care of by Mark Wielaard,
|
|
|
6240d7 |
here:
|
|
|
6240d7 |
|
|
|
6240d7 |
https://bugzilla.redhat.com/show_bug.cgi?id=1708786
|
|
|
6240d7 |
|
|
|
6240d7 |
However, I still feel it's important to make GDB more resilient
|
|
|
6240d7 |
against invalid DWARF input, so I'm proposing this rather simple patch
|
|
|
6240d7 |
to catch the situation when "body == NULL" (i.e., it's probably been
|
|
|
6240d7 |
corrupted) and issue a complaint. This is not a real fix to the
|
|
|
6240d7 |
problem, of course, but at least GDB is able to finish without
|
|
|
6240d7 |
segfaulting.
|
|
|
6240d7 |
|
|
|
6240d7 |
OK for master?
|
|
|
6240d7 |
|
|
|
6240d7 |
gdb/ChangeLog:
|
|
|
6240d7 |
2019-05-15 Sergio Durigan Junior <sergiodj@redhat.com>
|
|
|
6240d7 |
|
|
|
6240d7 |
Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1708192
|
|
|
6240d7 |
* dwarf2read.c (dwarf_decode_macro_bytes): Check whether 'body' is
|
|
|
6240d7 |
NULL, and complain if that's the case.
|
|
|
6240d7 |
|
|
|
6240d7 |
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
|
|
|
6240d7 |
--- a/gdb/ChangeLog
|
|
|
6240d7 |
+++ b/gdb/ChangeLog
|
|
|
6240d7 |
@@ -1,3 +1,9 @@
|
|
|
6240d7 |
+2019-05-15 Sergio Durigan Junior <sergiodj@redhat.com>
|
|
|
6240d7 |
+
|
|
|
6240d7 |
+ Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1708192
|
|
|
6240d7 |
+ * dwarf2read.c (parse_macro_definition): Check whether 'body' is
|
|
|
6240d7 |
+ NULL, and complain/return if that's the case.
|
|
|
6240d7 |
+
|
|
|
6240d7 |
2019-05-11 Joel Brobecker <brobecker@adacore.com>
|
|
|
6240d7 |
|
|
|
6240d7 |
* version.in: Set GDB version number to 8.3.
|
|
|
6240d7 |
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
|
|
|
6240d7 |
--- a/gdb/dwarf2read.c
|
|
|
6240d7 |
+++ b/gdb/dwarf2read.c
|
|
|
6240d7 |
@@ -24627,7 +24627,21 @@ dwarf_decode_macro_bytes (struct dwarf2_cu *cu,
|
|
|
6240d7 |
is_define ? _("definition") : _("undefinition"),
|
|
|
6240d7 |
line == 0 ? _("zero") : _("non-zero"), line, body);
|
|
|
6240d7 |
|
|
|
6240d7 |
- if (is_define)
|
|
|
6240d7 |
+ if (body == NULL)
|
|
|
6240d7 |
+ {
|
|
|
6240d7 |
+ /* Fedora's rpm-build's "debugedit" binary
|
|
|
6240d7 |
+ corrupted .debug_macro sections.
|
|
|
6240d7 |
+
|
|
|
6240d7 |
+ For more info, see
|
|
|
6240d7 |
+ https://bugzilla.redhat.com/show_bug.cgi?id=1708786 */
|
|
|
6240d7 |
+ complaint (_("debug info gives %s invalid macro %s "
|
|
|
6240d7 |
+ "without body (corrupted?) at line %d "
|
|
|
6240d7 |
+ "on file %s"),
|
|
|
6240d7 |
+ at_commandline ? _("command-line") : _("in-file"),
|
|
|
6240d7 |
+ is_define ? _("definition") : _("undefinition"),
|
|
|
6240d7 |
+ line, current_file->filename);
|
|
|
6240d7 |
+ }
|
|
|
6240d7 |
+ else if (is_define)
|
|
|
6240d7 |
parse_macro_definition (current_file, line, body);
|
|
|
6240d7 |
else
|
|
|
6240d7 |
{
|