From patchwork Mon Dec 11 07:01:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 846819 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-468886-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="Mj/NCiKx"; 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 3ywDRD6GQWz9s7F for ; Mon, 11 Dec 2017 18:02:16 +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=jRdoZaeoegEZ dB2qLpwHhADRJxnOLJbQPFPhtaraOu9LP9rQ8ouBccbynaVJefM3dEDeVZXGBRAa S5JJHoZxQ+/H1UbOsnYdK9lR2nRHxppFBSIhAFkgDsUUsHU33qp331apaEbpFX0o GB/MrHzE6rV3Q2MBmjKKq3Ekwk5Afpw= 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=ET6f1jTiCKoEaYoJXh HzrdxCjLQ=; b=Mj/NCiKx5ORv8464jQFCqLJQLPHX8uJMr7/RbuwibSldvXbK/8 7MH+7y2zkCFH+sYXJ/xShfapDN2JKdiDqApzHSSq/aYWXg4sMDvhchoC8+/cyyqR OfWpbnYgJOejcs2rEab9VcQD8wuagXddSO8Z4VLuO5ypo7LZaPDf7t8q0= Received: (qmail 88800 invoked by alias); 11 Dec 2017 07:02:07 -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 88703 invoked by uid 89); 11 Dec 2017 07:02:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.3 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:02:05 +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 97491874F4; Mon, 11 Dec 2017 08:02:02 +0100 (CET) Received: by firstfloor.org (Postfix, from userid 1000) id DCDF9A67A0; Sun, 10 Dec 2017 23:02:00 -0800 (PST) From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: Andi Kleen Subject: [PATCH] Fix segfault in inliner with attribute flatten Date: Sun, 10 Dec 2017 23:01:59 -0800 Message-Id: <20171211070159.26287-1-andi@firstfloor.org> From: Andi Kleen This fixes a segfault in gcc 7/8 when building turicreate. For some reason the node has no decl here, and there is a crash when checking for attribute flatten. gcc/: 2017-12-10 Andi Kleen PR ipa/83346 * ipa-inline.c (ipa_inline): Check for NULL pointer. gcc/testsuite: 2017-12-10 Andi Kleen * g++.dg/pr83346.C: Add. --- gcc/ipa-inline.c | 3 ++- gcc/testsuite/g++.dg/pr83346.C | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/pr83346.C diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index 7846e93d119..dcd8a3de1ac 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -2391,7 +2391,8 @@ ipa_inline (void) entry of cycles, possibly cloning that entry point and try to flatten itself turning it into a self-recursive function. */ - if (lookup_attribute ("flatten", + if (node->decl + && lookup_attribute ("flatten", DECL_ATTRIBUTES (node->decl)) != NULL) { if (dump_file) diff --git a/gcc/testsuite/g++.dg/pr83346.C b/gcc/testsuite/g++.dg/pr83346.C new file mode 100644 index 00000000000..2a916223dc9 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr83346.C @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +namespace { +template struct b { a c; }; +} +typedef int d; +namespace { +namespace { +template class ac; +typedef ac ad; +template class ac { +public: + ~ac(); +}; +} +typedef ad f; +struct g {}; +enum ag {}; +class ae { +public: + ~ae(); + template ae(h); + union aj { + b *ak; + struct { + ag al; + }; + } am; + __attribute__((always_inline)) void an(aj i, ag) { delete i.ak; } +} ao = g(); +__attribute__((always_inline, flatten)) ae::~ae() { an(am, am.al); } +}