This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: New FAIL on gdb.base/complex-parts.exp - unix/-m32
- From: Tom Tromey <tom at tromey dot com>
- To: Andrew Burgess <andrew dot burgess at embecosm dot com>
- Cc: Sergio Durigan Junior <sergiodj at redhat dot com>, gdb-patches at sourceware dot org, Richard Bunt <Richard dot Bunt at arm dot com>
- Date: Tue, 16 Apr 2019 12:30:48 -0600
- Subject: Re: New FAIL on gdb.base/complex-parts.exp - unix/-m32
- References: <cover.1552913183.git.andrew.burgess@embecosm.com> <854230b716fa6838bd2d8e73f1fd2d342a7a75ed.1552913183.git.andrew.burgess@embecosm.com> <87ftqndlb6.fsf_-_@redhat.com> <20190413000202.GF2737@embecosm.com>
>>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:
Andrew> The problem is that GDB tries to find a builtin floating point type of
Andrew> the correct size in order to reuse the name of that type as the name
Andrew> for the components of the complex type being built.
This patch caused a crash on an internal test case.
Let me know what you think of the appended.
thanks,
Tom
commit bf3507f7fcb6331401f9fd8eb7f1fad25ebfdf23
Author: Tom Tromey <tromey@adacore.com>
Date: Tue Apr 16 12:12:09 2019 -0600
Avoid crash in dwarf2_init_complex_target_type
After commit 35add35 ("gdb: Fix failure in gdb.base/complex-parts.exp
for x86-32"), dwarf2_init_complex_target_type can crash if "tt" is
nullptr. This patch avoids the problem by checking for this case.
No test case because I don't know a good way to write one; it was
found by an internal AdaCore test case that apparently uses a 16 bit
floating point type.
gdb/ChangeLog:
* dwarf2read.c (dwarf2_init_complex_target_type): Check "tt"
against nullptr before use.
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ba1300d57ef..9281d822ade 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2019-04-16 Tom Tromey <tromey@adacore.com>
+
+ * dwarf2read.c (dwarf2_init_complex_target_type): Check "tt"
+ against nullptr before use.
+
2019-04-15 Leszek Swirski <leszeks@google.com>
* amd64-tdep.c (amd64_classify_aggregate): Use cp_pass_by_reference
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 0873028e438..16bf2404a21 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -17566,7 +17566,7 @@ dwarf2_init_complex_target_type (struct dwarf2_cu *cu,
/* If the type we found doesn't match the size we were looking for, then
pretend we didn't find a type at all, the complex target type we
create will then be nameless. */
- if (TYPE_LENGTH (tt) * TARGET_CHAR_BIT != bits)
+ if (tt != nullptr && TYPE_LENGTH (tt) * TARGET_CHAR_BIT != bits)
tt = nullptr;
const char *name = (tt == nullptr) ? nullptr : TYPE_NAME (tt);