public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix dangling pointer in next_nested.
@ 2019-08-14 11:56 Martin Liska
  2019-08-14 12:01 ` [PATCH 1/2] Add ::verify for cgraph_node::origin/nested/next_nested Martin Liska
  2019-08-14 12:14 ` [PATCH 2/2] Clean next_nested properly Martin Liska
  0 siblings, 2 replies; 5+ messages in thread
From: Martin Liska @ 2019-08-14 11:56 UTC (permalink / raw)
  To: gcc-patches

Hi.

First patch is about addition of a nested/origin/next_nested verification.
The verification can find the issue in Ada run-time library on x86_64
without bootstrap.

The second patch is fix where we need to clean up the field.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

Martin Liska (2):
  Add ::verify for cgraph_node::origin/nested/next_nested.
  Clean next_nested properly.

 gcc/cgraph.c | 35 +++++++++++++++++++++++++++++++----
 1 file changed, 31 insertions(+), 4 deletions(-)

-- 
2.22.0

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] Add ::verify for cgraph_node::origin/nested/next_nested.
  2019-08-14 11:56 [PATCH 0/2] Fix dangling pointer in next_nested Martin Liska
@ 2019-08-14 12:01 ` Martin Liska
  2019-08-14 17:07   ` Jeff Law
  2019-08-14 12:14 ` [PATCH 2/2] Clean next_nested properly Martin Liska
  1 sibling, 1 reply; 5+ messages in thread
From: Martin Liska @ 2019-08-14 12:01 UTC (permalink / raw)
  To: gcc-patches

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


gcc/ChangeLog:

2019-08-14  Martin Liska  <mliska@suse.cz>

	* cgraph.c (cgraph_node::verify_node): Verify origin, nested
	and next_nested.
---
 gcc/cgraph.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-verify-for-cgraph_node-origin-nested-next_nested.patch --]
[-- Type: text/x-patch; name="0001-Add-verify-for-cgraph_node-origin-nested-next_nested.patch", Size: 792 bytes --]

diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index ed46d81a513..eb38b905879 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -3464,6 +3464,30 @@ cgraph_node::verify_node (void)
 	  e->aux = 0;
 	}
     }
+
+  if (nested != NULL)
+    {
+      for (cgraph_node *n = nested; n != NULL; n = n->next_nested)
+	{
+	  if (n->origin == NULL)
+	    {
+	      error ("missing origin for a node in a nested list");
+	      error_found = true;
+	    }
+	  else if (n->origin != this)
+	    {
+	      error ("origin points to a different parent");
+	      error_found = true;
+	      break;
+	    }
+	}
+    }
+  if (next_nested != NULL && origin == NULL)
+    {
+      error ("missing origin for a node in a nested list");
+      error_found = true;
+    }
+
   if (error_found)
     {
       dump (stderr);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] Clean next_nested properly.
  2019-08-14 11:56 [PATCH 0/2] Fix dangling pointer in next_nested Martin Liska
  2019-08-14 12:01 ` [PATCH 1/2] Add ::verify for cgraph_node::origin/nested/next_nested Martin Liska
@ 2019-08-14 12:14 ` Martin Liska
  2019-08-14 17:10   ` Jeff Law
  1 sibling, 1 reply; 5+ messages in thread
From: Martin Liska @ 2019-08-14 12:14 UTC (permalink / raw)
  To: gcc-patches

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


gcc/ChangeLog:

2019-08-14  Martin Liska  <mliska@suse.cz>

	PR ipa/91438
	* cgraph.c (cgraph_node::remove): When setting
	n->origin = NULL for all nested functions, reset
	also next_nested.
---
 gcc/cgraph.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-Clean-next_nested-properly.patch --]
[-- Type: text/x-patch; name="0002-Clean-next_nested-properly.patch", Size: 1105 bytes --]

diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index eb38b905879..ea8ab38d806 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -1767,8 +1767,6 @@ cgraph_node::release_body (bool keep_arguments)
 void
 cgraph_node::remove (void)
 {
-  cgraph_node *n;
-
   if (symtab->ipa_clones_dump_file && symtab->cloned_nodes.contains (this))
     fprintf (symtab->ipa_clones_dump_file,
 	     "Callgraph removal;%s;%d;%s;%d;%d\n", asm_name (), order,
@@ -1785,8 +1783,13 @@ cgraph_node::remove (void)
      */
   force_output = false;
   forced_by_abi = false;
-  for (n = nested; n; n = n->next_nested)
+  cgraph_node *next = nested;
+  for (cgraph_node *n = nested; n; n = next)
+  {
+    next = n->next_nested;
     n->origin = NULL;
+    n->next_nested = NULL;
+  }
   nested = NULL;
   if (origin)
     {
@@ -1840,7 +1843,7 @@ cgraph_node::remove (void)
      */
   if (symtab->state != LTO_STREAMING)
     {
-      n = cgraph_node::get (decl);
+      cgraph_node *n = cgraph_node::get (decl);
       if (!n
 	  || (!n->clones && !n->clone_of && !n->global.inlined_to
 	      && ((symtab->global_info_ready || in_lto_p)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] Add ::verify for cgraph_node::origin/nested/next_nested.
  2019-08-14 12:01 ` [PATCH 1/2] Add ::verify for cgraph_node::origin/nested/next_nested Martin Liska
@ 2019-08-14 17:07   ` Jeff Law
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff Law @ 2019-08-14 17:07 UTC (permalink / raw)
  To: Martin Liska, gcc-patches

On 8/14/19 5:15 AM, Martin Liska wrote:
> 
> gcc/ChangeLog:
> 
> 2019-08-14  Martin Liska  <mliska@suse.cz>
> 
> 	* cgraph.c (cgraph_node::verify_node): Verify origin, nested
> 	and next_nested.
> ---
>  gcc/cgraph.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
OK.
Jeff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] Clean next_nested properly.
  2019-08-14 12:14 ` [PATCH 2/2] Clean next_nested properly Martin Liska
@ 2019-08-14 17:10   ` Jeff Law
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff Law @ 2019-08-14 17:10 UTC (permalink / raw)
  To: Martin Liska, gcc-patches

On 8/14/19 5:17 AM, Martin Liska wrote:
> 
> gcc/ChangeLog:
> 
> 2019-08-14  Martin Liska  <mliska@suse.cz>
> 
> 	PR ipa/91438
> 	* cgraph.c (cgraph_node::remove): When setting
> 	n->origin = NULL for all nested functions, reset
> 	also next_nested.
> ---
>  gcc/cgraph.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
OK
jeff

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-08-14 17:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-14 11:56 [PATCH 0/2] Fix dangling pointer in next_nested Martin Liska
2019-08-14 12:01 ` [PATCH 1/2] Add ::verify for cgraph_node::origin/nested/next_nested Martin Liska
2019-08-14 17:07   ` Jeff Law
2019-08-14 12:14 ` [PATCH 2/2] Clean next_nested properly Martin Liska
2019-08-14 17:10   ` Jeff Law

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).