From patchwork Tue Apr 16 18:30:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 32307 Received: (qmail 68807 invoked by alias); 16 Apr 2019 18:30:53 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 68798 invoked by uid 89); 16 Apr 2019 18:30:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: gateway36.websitewelcome.com Received: from gateway36.websitewelcome.com (HELO gateway36.websitewelcome.com) (192.185.194.2) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 16 Apr 2019 18:30:51 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway36.websitewelcome.com (Postfix) with ESMTP id 2D0E8400C8B61 for ; Tue, 16 Apr 2019 12:48:44 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id GSr3h4yOA90onGSr3hG8Gn; Tue, 16 Apr 2019 13:30:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=6kQ7sMw0FmB5EsD3IvVxO9+VmvrdRnMctJGkLm41LO4=; b=K65Fn+QyRnGcCAoh9R3X9kZF4B UPVGxZLBwcvBZaE7lR47Ny+5gt0d31PzFRtF+wqFQ/UkE/13mdYnLo50gzuJhUUAmGM3FBdIylZd4 zdrdqdB8a/z94AlqUPUb6+NNb; Received: from 75-166-39-124.hlrn.qwest.net ([75.166.39.124]:44942 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1hGSr3-003UqO-8m; Tue, 16 Apr 2019 13:30:49 -0500 From: Tom Tromey To: Andrew Burgess Cc: Sergio Durigan Junior , gdb-patches@sourceware.org, Richard Bunt Subject: Re: New FAIL on gdb.base/complex-parts.exp - unix/-m32 References: <854230b716fa6838bd2d8e73f1fd2d342a7a75ed.1552913183.git.andrew.burgess@embecosm.com> <87ftqndlb6.fsf_-_@redhat.com> <20190413000202.GF2737@embecosm.com> Date: Tue, 16 Apr 2019 12:30:48 -0600 In-Reply-To: <20190413000202.GF2737@embecosm.com> (Andrew Burgess's message of "Sat, 13 Apr 2019 01:02:02 +0100") Message-ID: <87k1ftu7jb.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 >>>>> "Andrew" == Andrew Burgess 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 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 + + * dwarf2read.c (dwarf2_init_complex_target_type): Check "tt" + against nullptr before use. + 2019-04-15 Leszek Swirski * 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);