From patchwork Mon Dec 11 07:01:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 846818 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-468885-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="C8XfBd9G"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ywDR32Wf3z9s7F for ; Mon, 11 Dec 2017 18:02:03 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; q=dns; s=default; b=ym9a7+nS6fdR oEgqnetPyKFHFvYMv6h6wam5r58TrXw+/8l7w4oJSDdwsV23euVv+DoTxWym1rqA DpcQqJZnANbGH+n4z/53aiyyWc0/mYTZpor5dlDlmQJH+0F/X1Ue7lbNHsXcdjyr A2bbKjFho+NQqWY0TRIf8Z40Cs9fpvs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; s=default; bh=wlIBRayrb7ZeHUy/X1 H3DLAliqo=; b=C8XfBd9GxH226gEaWQYtbXlqkaKuxTNaVJaxZYryYGXgYv+ds5 k/1S4izrl6baJUMBdLeGYn4vREOdRYxVi83fiI88UxG27m2LGv0SaP3RW2y+Y3Wv Vha8au6ZfZfkv9mUEFKZJl/3ZQJvWS/84pxs6j3EURglCO97y9AODTUOA= Received: (qmail 87437 invoked by alias); 11 Dec 2017 07:01:53 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 87423 invoked by uid 89); 11 Dec 2017 07:01:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: one.firstfloor.org Received: from one.firstfloor.org (HELO one.firstfloor.org) (193.170.194.197) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 11 Dec 2017 07:01:51 +0000 Received: from firstfloor.org (174-25-38-10.ptld.qwest.net [174.25.38.10]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by one.firstfloor.org (Postfix) with ESMTPSA id C2A3B868AB; Mon, 11 Dec 2017 08:01:46 +0100 (CET) Received: by firstfloor.org (Postfix, from userid 1000) id 91E8AA67A0; Sun, 10 Dec 2017 23:01:44 -0800 (PST) From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: Andi Kleen Subject: [PATCH] Fix stack overflow with autofdo (PR83355) Date: Sun, 10 Dec 2017 23:01:43 -0800 Message-Id: <20171211070143.26129-1-andi@firstfloor.org> From: Andi Kleen g++.dg/bprob* is failing currently with autofdo. Running in gdb shows that there is a very deep recursion in get_index_by_decl until it overflows the stack. This patch seems to fix it (but not sure why the abstract origin would point to itself) Passes bootstrap and testing on x86_64-linux gcc/: 2017-12-10 Andi Kleen PR gcov-profile/83355 * auto-profile.c (string_table::get_index_by_decl): Don't recurse when abstract origin points to itself. --- gcc/auto-profile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c index 5134a795331..403709bad6b 100644 --- a/gcc/auto-profile.c +++ b/gcc/auto-profile.c @@ -477,7 +477,7 @@ string_table::get_index_by_decl (tree decl) const ret = get_index (lang_hooks.dwarf_name (decl, 0)); if (ret != -1) return ret; - if (DECL_ABSTRACT_ORIGIN (decl)) + if (DECL_ABSTRACT_ORIGIN (decl) && DECL_ABSTRACT_ORIGIN (decl) != decl) return get_index_by_decl (DECL_ABSTRACT_ORIGIN (decl)); return -1;