From patchwork Thu Nov 7 04:05:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Terekhov, Mikhail via Gdb-patches" X-Patchwork-Id: 35708 Received: (qmail 103162 invoked by alias); 7 Nov 2019 04:05:49 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 103154 invoked by uid 89); 7 Nov 2019 04:05:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=classified, inhouse, in-house, HX-HELO:sk:mail-ua X-HELO: mail-ua1-f74.google.com Received: from mail-ua1-f74.google.com (HELO mail-ua1-f74.google.com) (209.85.222.74) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 07 Nov 2019 04:05:47 +0000 Received: by mail-ua1-f74.google.com with SMTP id j7so357492uan.11 for ; Wed, 06 Nov 2019 20:05:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=G5sJCq+UPTGrgyYztTWLKMVomu3eOuUj2fzUGKd3wr4=; b=GWCc+Gn/4+zRZhALGgfMYDIDrdimhqmVETF/RmkAWend8Ur5f97a8B9fcE0ngXi8tB CPXPpbwHocW3kjsihG6t1S+zvr9jBAxtHh29tLGNZlqGo1NcYRxTcr1b58u8+bRLkDLJ U3yiANL9W9BgEJdBY7tLcVCxj/eUsOnL6wkaEySGY5Ad/aKl2bDDvJAxuVYYk3FDGiZh Yy37fHVLwfwi97N3OKGlI3kB/KgClvEK5m6JNsbBR/7Udm13jz/MZJhT+NwJoP/AGWAm JOjbKw3ZMTw8JVaLfeZo2cvA1R3qcgZfeSzyp3z+0Y8z7QXPm21UyPsF2UoEc+V/an5z u3yw== Date: Wed, 6 Nov 2019 20:05:41 -0800 Message-Id: <20191107040541.208168-1-tamur@google.com> Mime-Version: 1.0 Subject: [PATCH] Fix infinite recursion bug at get_msymbol_address. X-Patchwork-Original-From: "Ali Tamur via gdb-patches" From: "Terekhov, Mikhail via Gdb-patches" Reply-To: Ali Tamur To: gdb-patches@sourceware.org Cc: tom@tromey.com, Ali Tamur X-IsSubscribed: yes The patch 4b610737f0 seems to have introduced the possibility of infinite recursion. I have encountered the problem while debugging a failing in-house test. I am sorry, it is fairly difficult to reduce the test case (and I don't understand most of what is going on) but the stack trace shows a call to objfpy_add_separate_debug_file, which eventually causes lookup_minimal_symbol_by_pc_name to be invoked, which calls get_msymbol_address. Somehow lookup_minimal_symbol_linkage finds the same symbol and the function calls itself with the same parameters. I don't know whether this should be classified as 'it should never happen', but this simple patch makes the test pass and should be harmless, I think. gdb/ChangeLog * symtab.c (get_msymbol_address): Guard against infinite recursion. --- gdb/symtab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index 2c934b9c22..b231cc6e84 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -6328,7 +6328,7 @@ get_msymbol_address (struct objfile *objf, const struct minimal_symbol *minsym) { bound_minimal_symbol found = lookup_minimal_symbol_linkage (linkage_name, objfile); - if (found.minsym != nullptr) + if (found.minsym != nullptr && found.minsym != minsym) return BMSYMBOL_VALUE_ADDRESS (found); } }