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