From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTP id BFF1D386EC42 for ; Fri, 24 Apr 2020 14:51:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BFF1D386EC42 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey@adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 747A1116790; Fri, 24 Apr 2020 10:51:38 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 7-G8+6NzRS2Q; Fri, 24 Apr 2020 10:51:38 -0400 (EDT) Received: from murgatroyd.Home (184-96-229-138.hlrn.qwest.net [184.96.229.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 3232511678B; Fri, 24 Apr 2020 10:51:38 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Don't re-process a DIE in read_lexical_block_scope Date: Fri, 24 Apr 2020 08:51:36 -0600 Message-Id: <20200424145136.5348-1-tromey@adacore.com> X-Mailer: git-send-email 2.21.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-21.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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: , X-List-Received-Date: Fri, 24 Apr 2020 14:51:39 -0000 A customer reported a crash in the DWARF reader. Investigation showed that the crash occurred in an unusual scenario: a function was lexically scoped within some other function -- but the inner function inlined the outer function and referred to its DIE via DW_AT_abstract_origin. With the executable in question, inherit_abstract_dies could eventually call read_lexical_block_scope, which in turn could recurse into process_die, to process a DIE that was already being read, triggering an assert. This came up once before; see: https://www.sourceware.org/ml/gdb-patches/2014-02/msg00652.html However, in this case, I don't have an easy way to reproduce. So, there is no test case. I did experiment with the failing executable. This patch fixes the bug and doesn't seem to cause other issues. For example, I can still set breakpoints on the relevant functions. gdb/ChangeLog 2020-04-24 Tom Tromey * dwarf2/read.c (read_lexical_block_scope): Don't process a DIE already being processed. --- gdb/ChangeLog | 5 +++++ gdb/dwarf2/read.c | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index e89ed743543..9e4427e3cd7 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -13058,7 +13058,16 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu) for (child_die = die->child; child_die != NULL && child_die->tag; child_die = child_die->sibling) - process_die (child_die, cu); + { + /* We might already be processing this DIE. This can happen + in an unusual circumstance -- where a subroutine A + appears lexically in another subroutine B, but A actually + inlines B. The recursion is broken here, rather than in + inherit_abstract_dies, because it seems better to simply + drop concrete children here. */ + if (!child_die->in_process) + process_die (child_die, cu); + } return; case PC_BOUNDS_INVALID: return; -- 2.21.1