https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121588

--- Comment #12 from Peter Frost <mail at pfrost dot me> ---
NULL dereference of `lto_file_data` seems to be quite a common bug, I found a
couple of bugs referring to ICE with LTO caused by it:

- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69133
- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65012


Just out of interest I added an early return in the calling function
`cgraph_node::get_untransformed_body`:

--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -4069,5 +4069,5 @@ cgraph_node::get_untransformed_body ()
   /* Check if body is already there.  Either we have gimple body or
      the function is thunk and in that case we set DECL_ARGUMENTS.  */
-  if (DECL_ARGUMENTS (decl) || gimple_has_body_p (decl))
+  if (DECL_ARGUMENTS (decl) || gimple_has_body_p (decl) || !lto_file_data)
     return false;

Which does indeed stop the NULL dereference, but instead it just causes an
assert a few lines later in the caller: `ipa_icf::sem_function::init` on line
1366. I'm not familiar enough with gcc so I've no idea if there's something
clever that can be done to recover from this scenario, or if this should raise
a fatal error.

Reply via email to