cgraph: Avoid segfault when attempting to dump NULL clone_info

Message ID ri64kluze8e.fsf@suse.cz
State New
Headers show
Series
  • cgraph: Avoid segfault when attempting to dump NULL clone_info
Related show

Commit Message

Martin Jambor Nov. 12, 2020, 5:17 p.m.
Hi,

cgraph_node::materialize_clone segfaulted when I tried compiling Tramp3D
with -fdump-ipa-all because there was no clone_info - IPA-CP created a
clone only for an aggregate constant, adding a note to its
transformation summary but not creating any tree_map nor
param_adjustements.

Fixed with the following obvious extra checks which I will commit after
an obligatory round of bootstrap and testing.

Thanks,

Martin


gcc/ChangeLog:

2020-11-12  Martin Jambor  <mjambor@suse.cz>

	* cgraphclones.c (cgraph_node::materialize_clone): Check that clone
	info is not NULL before attempting to dump it.
---
 gcc/cgraphclones.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.29.2

Comments

Jan Hubicka Nov. 12, 2020, 5:19 p.m. | #1
> Hi,

> 

> cgraph_node::materialize_clone segfaulted when I tried compiling Tramp3D

> with -fdump-ipa-all because there was no clone_info - IPA-CP created a

> clone only for an aggregate constant, adding a note to its

> transformation summary but not creating any tree_map nor

> param_adjustements.

> 

> Fixed with the following obvious extra checks which I will commit after

> an obligatory round of bootstrap and testing.

> 

> Thanks,

> 

> Martin

> 

> 

> gcc/ChangeLog:

> 

> 2020-11-12  Martin Jambor  <mjambor@suse.cz>

> 

> 	* cgraphclones.c (cgraph_node::materialize_clone): Check that clone

> 	info is not NULL before attempting to dump it.

OK, thanks!
Honza
> ---

>  gcc/cgraphclones.c | 4 ++--

>  1 file changed, 2 insertions(+), 2 deletions(-)

> 

> diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c

> index bc590819f78..712a54e8d0c 100644

> --- a/gcc/cgraphclones.c

> +++ b/gcc/cgraphclones.c

> @@ -1107,7 +1107,7 @@ cgraph_node::materialize_clone ()

>        fprintf (symtab->dump_file, "cloning %s to %s\n",

>  	       clone_of->dump_name (),

>  	       dump_name ());

> -      if (info->tree_map)

> +      if (info && info->tree_map)

>          {

>  	  fprintf (symtab->dump_file, "    replace map:");

>  	  for (unsigned int i = 0;

> @@ -1123,7 +1123,7 @@ cgraph_node::materialize_clone ()

>  	    }

>  	  fprintf (symtab->dump_file, "\n");

>  	}

> -      if (info->param_adjustments)

> +      if (info && info->param_adjustments)

>  	info->param_adjustments->dump (symtab->dump_file);

>      }

>    clear_stmts_in_references ();

> -- 

> 2.29.2

>

Patch

diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index bc590819f78..712a54e8d0c 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -1107,7 +1107,7 @@  cgraph_node::materialize_clone ()
       fprintf (symtab->dump_file, "cloning %s to %s\n",
 	       clone_of->dump_name (),
 	       dump_name ());
-      if (info->tree_map)
+      if (info && info->tree_map)
         {
 	  fprintf (symtab->dump_file, "    replace map:");
 	  for (unsigned int i = 0;
@@ -1123,7 +1123,7 @@  cgraph_node::materialize_clone ()
 	    }
 	  fprintf (symtab->dump_file, "\n");
 	}
-      if (info->param_adjustments)
+      if (info && info->param_adjustments)
 	info->param_adjustments->dump (symtab->dump_file);
     }
   clear_stmts_in_references ();