From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 73O+E/cJlGDVJQAAWB0awg (envelope-from ) for ; Thu, 06 May 2021 11:23:35 -0400 Received: by simark.ca (Postfix, from userid 112) id 429351F11C; Thu, 6 May 2021 11:23:35 -0400 (EDT) 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 294A51E54D for ; Thu, 6 May 2021 11:23:31 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A3DDA388CC14; Thu, 6 May 2021 15:23:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A3DDA388CC14 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1620314610; bh=hREssA8deLLlwx3L5bCOmRuc4u1u5/oIjUsHMZh1aVY=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=t2LXhYqxRm7bGmw7R9gpEyrqzD0kAzMGPGdHyD7gk0Jxq/NWdlOoelnTYt2Wkgq/r 1VtevPRf7S5Nd221tia72nb2UleivzSba4lsdSRV0bczEI2nSuYh9qHzp9XamhDmLp KmV8gmsgf/iIbAMvaM/sk3GJlLamE42CTHmOUYow= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id C16993857C56 for ; Thu, 6 May 2021 15:23:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C16993857C56 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 146FNMxr017114 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 6 May 2021 11:23:26 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 146FNMxr017114 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 8BD311E54D; Thu, 6 May 2021 11:23:21 -0400 (EDT) Subject: Re: [PATCH][gdb/symtab] Fix infinite recursion in dwarf2_cu::get_builder() To: Tom de Vries , gdb-patches@sourceware.org References: <20210506120247.GA1559@delia.home> Message-ID: Date: Thu, 6 May 2021 11:23:21 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210506120247.GA1559@delia.home> 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 Thu, 6 May 2021 15:23:22 +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 Cc: Tom Tromey Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 2021-05-06 8:02 a.m., Tom de Vries wrote: > Hi, > > With the test-case attached in PR26327, gdb aborts: > ... > $ gdb -q -batch 447.dealII -ex "b main" > Aborted (core dumped) > ... > when running out of stack due to infinite recursion: > ... > #8 0x00000000006aaba6 in dwarf2_cu::get_builder (this=0x35e4b40) > at src/gdb/dwarf2/read.c:700 > #9 0x00000000006aaba6 in dwarf2_cu::get_builder (this=0x22ee2c0) > at src/gdb/dwarf2/read.c:700 > #10 0x00000000006aaba6 in dwarf2_cu::get_builder (this=0x35e4b40) > at src/gdb/dwarf2/read.c:700 > #11 0x00000000006aaba6 in dwarf2_cu::get_builder (this=0x22ee2c0) > at src/gdb/dwarf2/read.c:700 > ... > > We're recursing in this code in dwarf2_cu::get_builder(): > ... > /* Otherwise, search ancestors for a valid builder. */ > if (ancestor != nullptr) > return ancestor->get_builder (); > ... > due to the fact that the ancestor chain is a cycle. > > Higher up in the call stack, we find some code that is responsible for > triggering this, in new_symbol: > ... > case DW_TAG_formal_parameter: > { > /* If we are inside a function, mark this as an argument. If > not, we might be looking at an argument to an inlined function > when we do not have enough information to show inlined frames; > pretend it's a local variable in that case so that the user can > still see it. */ > struct context_stack *curr > = cu->get_builder ()->get_current_context_stack (); > if (curr != nullptr && curr->name != nullptr) > SYMBOL_IS_ARGUMENT (sym) = 1; > ... > > This is code that was added to support pre-4.1 gcc, to be able to show > arguments of inlined functions as locals, in the absense of sufficiently > correct debug information. > > Removing this code (that is, doing SYMBOL_IS_ARGUMENT (sym) = 1 > unconditially), fixes the crash. The ancestor variable also seems to have > been added specifically to deal with fallout from this code, so remove that as > well. > > Tested on x86_64-linux: > - openSUSE Leap 15.2 with gcc 7.5.0, and > - openSUSE Tumbleweed with gcc 10.3.0. > > Any comments? I did not study the problem in depth like you did, but based on your explanation I think this is reasonable. If support for ancient stuff gets in the way of supporting modern stuff (like LTO), then it makes sense to remove the support for the ancient stuff. Simon