From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTP id 4264B385DC09 for ; Fri, 3 Apr 2020 16:58:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4264B385DC09 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 204251168E9; Fri, 3 Apr 2020 12:58:40 -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 lchhymgAnYgD; Fri, 3 Apr 2020 12:58:40 -0400 (EDT) Received: from murgatroyd.Home (174-16-110-145.hlrn.qwest.net [174.16.110.145]) (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 D26FB11667D; Fri, 3 Apr 2020 12:58:39 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 2/2] Avoid infinite recursion in get_msymbol_address Date: Fri, 3 Apr 2020 10:58:38 -0600 Message-Id: <20200403165838.9255-3-tromey@adacore.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200403165838.9255-1-tromey@adacore.com> References: <20200403165838.9255-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-22.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, 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, 03 Apr 2020 16:58:41 -0000 Sometimes, get_msymbol_address can cause infinite recursion, leading to a crash. This was reported previously here: https://sourceware.org/pipermail/gdb-patches/2019-November/162154.html A user on irc reported this as well, and with his help and the help of a friend of his, we found that the problem occurred because, when reloading a separate debug objfile, the objfile would lose the OBJF_MAINLINE flag. This would cause some symbols from this separate debug objfile to be marked "maybe_copied" -- but then get_msymbol_address could find the same symbol and fail as reported. This patch fixes the bug by preserving OBJF_MAINLINE. No test case, unfortunately, because I could not successfully make one. gdb/ChangeLog 2020-04-03 Tom Tromey * symfile.c (symbol_file_add_separate): Preserve OBJF_MAINLINE. --- gdb/ChangeLog | 4 ++++ gdb/symfile.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/gdb/symfile.c b/gdb/symfile.c index bd27a1fefef..61053298a89 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1163,7 +1163,7 @@ symbol_file_add_separate (bfd *bfd, const char *name, symbol_file_add_with_addrs (bfd, name, symfile_flags, &sap, objfile->flags & (OBJF_REORDERED | OBJF_SHARED | OBJF_READNOW - | OBJF_USERLOADED), + | OBJF_USERLOADED | OBJF_MAINLINE), objfile); } -- 2.21.1