public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Nathan Sidwell <nathan@acm.org>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [PR c++/81229] Dangling GC pointer
Date: Fri, 30 Jun 2017 11:43:00 -0000	[thread overview]
Message-ID: <07d01e1e-1548-a46b-224c-2e49e4e5e3e6@acm.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 642 bytes --]

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
-- 
Nathan Sidwell

[-- Attachment #2: pr81229.diff --]
[-- Type: text/x-patch, Size: 1464 bytes --]

2017-06-30  Nathan Sidwell  <nathan@acm.org>

	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;

                 reply	other threads:[~2017-06-30 11:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=07d01e1e-1548-a46b-224c-2e49e4e5e3e6@acm.org \
    --to=nathan@acm.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).