From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id KIRhC3opGGCmDAAAWB0awg (envelope-from ) for ; Mon, 01 Feb 2021 11:16:58 -0500 Received: by simark.ca (Postfix, from userid 112) id 1FA741EF80; Mon, 1 Feb 2021 11:16:58 -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.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 59E781E939 for ; Mon, 1 Feb 2021 11:16:57 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D6445382D830; Mon, 1 Feb 2021 16:16:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D6445382D830 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1612196216; bh=uSXlaaE9xoowYmGfd35LxYcrhl7qFk/iO9JOiSilNY0=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=mgg3shxfUPVu4lz0mixdL9lhzWN/pIzXvYKgSXu9hcjr2v2v/pFupOSOJ8XL6lDs+ PT9rrV8hHV2LsXVZBYaYsmu/j1lmU/nhjwBOoM0TuvqMw8fEK7pnVfOR+BPJGWsZJv qTyeIUq90xaD8juYHzYPBdMIvPue0iaS9Vc3yYXA= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 4E63A382D830 for ; Mon, 1 Feb 2021 16:16:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4E63A382D830 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 111GGlj0018722 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 1 Feb 2021 11:16:52 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 111GGlj0018722 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 7E0D41E939; Mon, 1 Feb 2021 11:16:47 -0500 (EST) Subject: Re: [PATCH][gdb/symtab] Fix assert in write_one_signatured_type To: Tom de Vries , gdb-patches@sourceware.org References: <20210201144321.GA1874@delia> Message-ID: Date: Mon, 1 Feb 2021 11:16:47 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <20210201144321.GA1874@delia> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 1 Feb 2021 16:16:47 +0000 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: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 2021-02-01 9:43 a.m., Tom de Vries wrote:> Hi, > > When running test-case gdb.dwarf2/fission-reread.exp with target board > cc-with-gdb-index, we run into an abort during the generation of the gdb-index > by cc-with-tweaks.sh: > ... > build/gdb/testsuite/cache/gdb.sh: line 1: 27275 Aborted (core dumped) > ... > > This can be reproduced on the command line like this: > ... > $ gdb -batch ./outputs/gdb.dwarf2/fission-reread/fission-reread \ > -ex 'save gdb-index ./outputs/gdb.dwarf2/fission-reread' > warning: Could not find DWO TU fission-reread.dwo(0x9022f1ceac7e8b19) \ > referenced by TU at offset 0x0 [in module fission-reread] > warning: Could not find DWO CU fission-reread.dwo(0x807060504030201) \ > referenced by CU at offset 0x561 [in module fission-reread] > Aborted (core dumped) > ... > > The abort is a segfault due to a using a nullptr psymtab in > write_one_signatured_type. > > The problem is that we're trying to write index entries for the type unit > with signature: > ... > (gdb) p /x entry->signature > $2 = 0x9022f1ceac7e8b19 > ... > which is a skeleton type unit: > ... > Contents of the .debug_types section: > > Compilation Unit @ offset 0x0: > Length: 0x4a (32-bit) > Version: 4 > Abbrev Offset: 0x165 > Pointer Size: 4 > Signature: 0x9022f1ceac7e8b19 > Type Offset: 0x0 > <0><17>: Abbrev Number: 2 (DW_TAG_type_unit) > <18> DW_AT_comp_dir : /tmp/src/gdb/testsuite > <2f> DW_AT_GNU_dwo_name: fission-reread.dwo > <42> DW_AT_GNU_pubnames: 0x0 > <46> DW_AT_GNU_pubtypes: 0x0 > <4a> DW_AT_GNU_addr_base: 0x0 > ... > referring to a .dwo file, but as the warnings show, the .dwo file is not > found. > > Fix this by skipping the type unit in write_one_signatured_type if > psymtab == nullptr. > > Tested on x86_64-linux. > > Any comments? > > Thanks, > - Tom > > [gdb/symtab] Fix assert in write_one_signatured_type > > gdb/ChangeLog: > > 2021-02-01 Tom de Vries > > PR symtab/24620 > * dwarf2/index-write.c (write_one_signatured_type): Skip if > psymtab == nullptr. > > --- > gdb/dwarf2/index-write.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c > index 66781feaf46..a7b9ae66cae 100644 > --- a/gdb/dwarf2/index-write.c > +++ b/gdb/dwarf2/index-write.c > @@ -616,6 +616,14 @@ write_one_signatured_type (void **slot, void *d) > struct signatured_type *entry = (struct signatured_type *) *slot; > partial_symtab *psymtab = entry->per_cu.v.psymtab; > > + if (psymtab == nullptr) > + { > + /* We can end up here when processing a skeleton CU referring to a > + .dwo file that hasn't been found. There's not much we can do in > + such a case, so skip this CU. */ > + return 1; > + } > + > write_psymbols (info->symtab, info->psyms_seen, > psymtab->global_psymbols, info->cu_index, > 0); > LGTM, some questions: 1. Do we need to emit a warning here? Probably not because another one should have been emitted earlier, when parsing symbols. But I thought I'd ask just in case. 2. Would it be somewhat easy to write a test for this? Have a type unit with a dwo, delete the dwo, try to generate an index. 3. Is the same situation correctly handled for standard compile units? Simon