From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id CEa6OuU5HWCJHgAAWB0awg (envelope-from ) for ; Fri, 05 Feb 2021 07:28:21 -0500 Received: by simark.ca (Postfix, from userid 112) id E212F1EFCB; Fri, 5 Feb 2021 07:28:21 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 389621E590 for ; Fri, 5 Feb 2021 07:28:21 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8AF3139D6074; Fri, 5 Feb 2021 12:28:20 +0000 (GMT) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 4FD5939D6074 for ; Fri, 5 Feb 2021 12:28:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4FD5939D6074 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 710DEACD4 for ; Fri, 5 Feb 2021 12:28:17 +0000 (UTC) Date: Fri, 5 Feb 2021 13:28:15 +0100 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH][gdb/symtab] Fix element type modification in read_array_type Message-ID: <20210205122814.GA19232@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Hi, When running test-case gdb.fortran/function-calls.exp with target board unix/gdb:debug_flags=-gdwarf-5, I run into: ... (gdb) PASS: gdb.fortran/function-calls.exp: \ p derived_types_and_module_calls::pass_cart(c) p derived_types_and_module_calls::pass_cart_nd(c_nd)^M ^M Program received signal SIGSEGV, Segmentation fault.^M 0x0000000000400f73 in derived_types_and_module_calls::pass_cart_nd \ (c=) at \ function-calls.f90:130^M 130 pass_cart_nd = ubound(c%d,1,4)^M The program being debugged was signaled while in a function called from GDB.^M GDB has restored the context to what it was before the call.^M To change this behavior use "set unwindonsignal off".^M Evaluation of the expression containing the function^M (derived_types_and_module_calls::pass_cart_nd) will be abandoned.^M (gdb) FAIL: gdb.fortran/function-calls.exp: p ... The problem originates in read_array_type, when reading a DW_TAG_array_type with a dwarf-5 DW_TAG_generic_subrange child. This is not supported, and the fallout of this is that rather than constructing a new array type, the code proceeds to modify the element type. Fix this conservatively by bailing out in read_array_type when not being able to construct an array type. Tested on x86_64-linux. Any comments? Thanks, - Tom [gdb/symtab] Fix element type modification in read_array_type gdb/ChangeLog: 2021-02-05 Tom de Vries PR symtab/27341 * dwarf2/read.c (read_array_type): Return NULL when not being able to construct an array type. --- gdb/dwarf2/read.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index f60e418172c..98189f7b566 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -17243,6 +17243,9 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) } } + if (type == element_type) + return NULL; + /* Understand Dwarf2 support for vector types (like they occur on the PowerPC w/ AltiVec). Gcc just adds another attribute to the array type. This is not part of the Dwarf2/3 standard yet, but a