Patchwork Fix PR target/48807

login
register
mail settings
Submitter Henderson, Stuart
Date May 19, 2011, 12:39 p.m.
Message ID <05E9E85E39C35B4D96ED3A3190E35A10A49CDA1888@LIMKCMBX1.ad.analog.com>
Download mbox | patch
Permalink /patch/96369/
State New
Headers show

Comments

Henderson, Stuart - May 19, 2011, 12:39 p.m.
Ping
http://gcc.gnu.org/ml/gcc-patches/2011-05/msg00503.html


Hi,
The attached patch is a fix for PR/48807, which is a segfault when compiling the bfin compiler.  The problem appears to be that we're not checking the return value of cgraph_local_info for null before attempting to dereference it.  This wasn't a problem before, but now cgraph_local_info calls cgraph_get_node (instead of the old cgraph_node), we cannot assume it will always return non-null.

Fix is in bfin specific code.

Ok to commit to trunk?

Stu


2011-05-06  Stuart Henderson  <shenders@gcc.gnu.org>

    * config/bfin/bfin.c: Check return value of cgraph_local_info for null before
        attempting to use it.
Bernd Schmidt - May 26, 2011, 1:23 p.m.
On 05/19/2011 12:39 PM, Henderson, Stuart wrote:
>     * config/bfin/bfin.c: Check return value of cgraph_local_info for null before
>         attempting to use it.

Needs to mention the function name, and wrap the long line properly.

> Index: gcc/config/bfin/bfin.c
> ===================================================================
> --- gcc/config/bfin/bfin.c      (revision 173363)
> +++ gcc/config/bfin/bfin.c      (working copy)
> @@ -2077,6 +2077,8 @@

Using the "-p" option for diff is preferrable. See
  http://gcc.gnu.org/wiki/SvnTricks

>    this_func = cgraph_local_info (current_function_decl);
>    called_func = cgraph_local_info (decl);
> +  if (!called_func || !this_func)
> +    return false;
>    return !called_func->local || this_func->local;
>  }

Ok, although I think this_func should never be NULL?


Bernd

Patch

Index: gcc/config/bfin/bfin.c
===================================================================
--- gcc/config/bfin/bfin.c      (revision 173363)
+++ gcc/config/bfin/bfin.c      (working copy)
@@ -2077,6 +2077,8 @@ 

   this_func = cgraph_local_info (current_function_decl);
   called_func = cgraph_local_info (decl);
+  if (!called_func || !this_func)
+    return false;
   return !called_func->local || this_func->local;
 }