From patchwork Fri Jun 30 11:43:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 782817 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3wzZRW1n5pz9sNS for ; Fri, 30 Jun 2017 21:43:33 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="DyIGgcGk"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=xTeYTiMByPdCKUbpdj7IObKhjjp6p30nn9EXFUrI6tHualTO/7 qa0AanYtRPw3t+H5LGcwQN8xlQZg3K+yLSeR5taIxOlyT5am7LSMgfnArHVp7zBv gJ6CHJg6UxFBxMC8p9m3ln3dTfEdV6RD0fYeeEaBdiDBIgOnNLHBlJWKY= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=tXSvvHZei8OCG0yFPVx7dRiKVig=; b=DyIGgcGkieha0sDQf5Xk 4zbfQRb8PBhXk3mf2Fu87lk2XlUU4UAhik5w38gbG/sX256K/jva1Xb7ti5AbVPq 7MrkqeGnCZznxzxg6QT/agKnTe3pMEsH/eoJU8BgdO4MPPOebuKrlIeIoMjcvCXi Se1JHT+7PmCTOAx9ZeEllyk= Received: (qmail 118450 invoked by alias); 30 Jun 2017 11:43:16 -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 117354 invoked by uid 89); 30 Jun 2017 11:43:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2058 X-HELO: mail-yb0-f182.google.com Received: from mail-yb0-f182.google.com (HELO mail-yb0-f182.google.com) (209.85.213.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 30 Jun 2017 11:43:14 +0000 Received: by mail-yb0-f182.google.com with SMTP id s15so3183603ybe.2 for ; Fri, 30 Jun 2017 04:43:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=VYN+967WsJWkCV/gIf3ARXCchTZD4rSHLeuSSGdGPGo=; b=GOw3kW9EXiBSiGwnf3Xtk1NzydsRjsjLjCqzyz/R+mPK7KgnZP0z3UKUA8vXMHCyM4 w3mGIslo0vXM/OnY6tyIcJD2tnN2I780zEKne3+hfg4R6RI3NABxVf9k40mS+OYHYrDD zTjU+lc+oYQB7v7aQSv34DxLH3MWRwCPSMqwhDVhhqRgWjvvrCz8x8u0w+EOyBWu293B poybNyhCFIidhi7XBY/JW2XzMfTNfCvCoWK0AuI+wsbIu4BApiOqU9nXgBH+qwuKEm5f ldZx4fXkFhs7tV2trGteSX3tYOrGFy5pLTJpE3oEslOlb3xDoYyEpVLJR2U2AACJrGbW KtLw== X-Gm-Message-State: AKS2vOzdfH6kD38h1R7MTi61vpfuYj9kHu1JieIFDbiaXQYDKmwKvpKP RFDPUYqhqGlZaw== X-Received: by 10.37.223.79 with SMTP id w76mr8883862ybg.149.1498822992587; Fri, 30 Jun 2017 04:43:12 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::1:9018]) by smtp.googlemail.com with ESMTPSA id t140sm3216818ywe.6.2017.06.30.04.43.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 04:43:12 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [PR c++/81229] Dangling GC pointer Message-ID: <07d01e1e-1548-a46b-224c-2e49e4e5e3e6@acm.org> Date: Fri, 30 Jun 2017 07:43:10 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 This fixes 81229, an ICE during GC. When converting the namespace symbol handling I was mystified by a SET_IDENTIFIER_TYPE call that seemingly had no effect. Turns out it is needed, because we've already set the IDENTIFIER_TYPE to the new decl's type. Whose name points back at the new TYPE_DECL. Which duplicate_decls gcc_freed when it found the already matched one. So we need to change IDENTIFIER_TYPE to the old decl's type node. This problem didn't manifest on a non-attributed int typedef, not sure why. I suspect I'll be coming back to revisit this code as my symbol table overhaul continues. nathan 2017-06-30 Nathan Sidwell PR c++/81229 * name-lookup.c (do_pushdecl): Reset IDENTIFIER_TYPE when finding a matching TYPE_DECL. * g++.dg/lookup/pr81229.C: New. Index: gcc/cp/name-lookup.c =================================================================== --- gcc/cp/name-lookup.c (revision 249834) +++ gcc/cp/name-lookup.c (working copy) @@ -2354,9 +2354,13 @@ do_pushdecl (tree decl, bool is_friend) ; /* Ignore using decls here. */ else if (tree match = duplicate_decls (decl, *iter, is_friend)) { - if (iter.hidden_p () - && match != error_mark_node - && !DECL_HIDDEN_P (match)) + if (match == error_mark_node) + ; + else if (TREE_CODE (match) == TYPE_DECL) + /* The IDENTIFIER will have the type referring to the + now-smashed TYPE_DECL, because ...? Reset it. */ + SET_IDENTIFIER_TYPE_VALUE (name, TREE_TYPE (match)); + else if (iter.hidden_p () && !DECL_HIDDEN_P (match)) { /* Unhiding a previously hidden decl. */ tree head = iter.reveal_node (old); Index: gcc/testsuite/g++.dg/lookup/pr81229.C =================================================================== --- gcc/testsuite/g++.dg/lookup/pr81229.C (revision 0) +++ gcc/testsuite/g++.dg/lookup/pr81229.C (working copy) @@ -0,0 +1,7 @@ +// PR c++/81229 GC ICE with stale pointed in identifier type. +// { dg-additional-options "--param ggc-min-heapsize=0" } + +typedef unsigned L; +typedef unsigned L; + +L l;