Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Don't crash if parse_definition_macro's 'body' is NULL
@ 2019-05-10 21:04 Sergio Durigan Junior
  2019-05-13 14:01 ` Tom Tromey
  0 siblings, 1 reply; 13+ messages in thread
From: Sergio Durigan Junior @ 2019-05-10 21:04 UTC (permalink / raw)
  To: GDB Patches; +Cc: Sergio Durigan Junior

Hi,

Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1708192
      https://bugzilla.redhat.com/show_bug.cgi?id=1708786

Fedora's rpm-build's "debugedit" program will silently corrupt
.debug_macro strings when a binary is compiled with -g3.  Later in the
build phase, 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.

This very simple patch is just a safeguard against this scenario; it
is not a fix for the problem (which actually happens on "debugedit",
and which Mark Wielaard is already working on), but at least it makes
GDB not crash on invalid DWARF, which is a plus IMO.

OK for master?

gdb/ChangeLog:
2019-05-10  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.
---
 gdb/ChangeLog    | 6 ++++++
 gdb/dwarf2read.c | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4da409633a..53a4721cb3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2019-05-10  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-10  Simon Marchi  <simon.marchi@efficios.com>
 
 	* contrib/cc-with-tweaks.sh: Validate dwz's work.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index b29c089606..e270e7cef3 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -24161,6 +24161,13 @@ parse_macro_definition (struct macro_source_file *file, int line,
 {
   const char *p;
 
+  if (body == NULL)
+    {
+      complaint (_("macro debug info contains a malformed "
+		   "(null) macro definition"));
+      return;
+    }
+
   /* The body string takes one of two forms.  For object-like macro
      definitions, it should be:
 
-- 
2.17.2


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-05-29 20:16 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-10 21:04 [PATCH] Don't crash if parse_definition_macro's 'body' is NULL Sergio Durigan Junior
2019-05-13 14:01 ` Tom Tromey
2019-05-14 20:54   ` Sergio Durigan Junior
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox