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