[Bug middle-end/79755] [8/9/10 Regression] ICE: segfault in cgraph_node::get, at cgraph.h:1261

2020-03-17 Thread xerofoify at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79755

--- Comment #17 from Nicholas Krause  ---
Sorry about that. I've managed to track it down to a problem with a alias issue 
And from reading the code in the original cvs commit. I'm not able to read it
currently but the original function mentioned seems to now be
cgraph_edge::verify_corresponds_to_fndecl. I've tried to access the original
commit but it complains about permissions. Maybe I'm wrong but this seems very
odd to me:
node = node->ultimate_alias_target ();

is basically referring to itself meaning:
if (callee->former_clone_of != node->decl
  && (node != node->ultimate_alias_target ())
  && !clone_of_p (node, callee))

the && (node != node->ultimate_alias_target ()) is basically referring to
itself when comparing yet its already being defined equal to the return value
of ultimate_alias_target meaning its always true. Not sure if this fixes this
bug or something else. Thoughts?

[Bug middle-end/79755] [8/9/10 Regression] ICE: segfault in cgraph_node::get, at cgraph.h:1261

2020-03-17 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79755

Marek Polacek  changed:

   What|Removed |Added

 CC||mpolacek at gcc dot gnu.org

--- Comment #16 from Marek Polacek  ---
That patch will generate a -Wparentheses warning, and more importantly, doesn't
fix the ICE, which you could have tried by yourself.

[Bug middle-end/79755] [8/9/10 Regression] ICE: segfault in cgraph_node::get, at cgraph.h:1261

2020-03-17 Thread xerofoify at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79755

--- Comment #15 from Nicholas Krause  ---
(In reply to Nicholas Krause from comment #14)
> Created attachment 48052 [details]
> Patch for this bug

After tracking this down to the new function that replaced
verify_edge_corresponds_to_fndecl, cgraph_edge::verify_corresponds_to_fndecl
which is basically the same we run into this:
if (callee->former_clone_of != node->decl
  && (node != callee->ultimate_alias_target ())
  && !clone_of_p (node, callee))


 Basically it appears to be checking we are a former cgraph clone at the same
time as being a current clone or the same node with clone_of_p on the callee
cgraph node. I'm attaching a test patch for this. Gerhard does this fix the
issue?

[Bug middle-end/79755] [8/9/10 Regression] ICE: segfault in cgraph_node::get, at cgraph.h:1261

2020-03-17 Thread xerofoify at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79755

Nicholas Krause  changed:

   What|Removed |Added

 CC||xerofoify at gmail dot com

--- Comment #14 from Nicholas Krause  ---
Created attachment 48052
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48052=edit
Patch for this bug

[Bug middle-end/79755] [8/9/10 Regression] ICE: segfault in cgraph_node::get, at cgraph.h:1261

2020-03-05 Thread xerofoify at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79755

--- Comment #13 from Nicholas Krause  ---
Please forget the previous comment in verify_edge_corresponds_to_fndecl we need
to switch it to this:
if (e->callee->former_clone_of != node->symbol.decl
&& (!n->symbol.cpp_implicit_alias
|| e->callee->former_clone_of != alias_node->symbol.alias_target ))

from the current:
 if (e->callee->former_clone_of != node->symbol.decl

as those other cases are missing in the patch posted after looking at it.

[Bug middle-end/79755] [8/9/10 Regression] ICE: segfault in cgraph_node::get, at cgraph.h:1261

2020-03-05 Thread xerofoify at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79755

--- Comment #12 from Nicholas Krause  ---
Sorry about not reading the comment carefully.

I'm not if this helps but after looking at the change to this file:
https://gcc.gnu.org/viewcvs/gcc/trunk/gcc/cgraph.c?r1=199577=199576=199577

n = cgraph_create_function_alias (alias, decl);

was never changed for creating with the new function arguments as found here:
struct cgraph_node *
cgraph_create_function_alias (tree alias, tree target)

and therefore it should be:

n = cgraph_create_function_alias (alias, target);

and not decl.

[Bug middle-end/79755] [8/9/10 Regression] ICE: segfault in cgraph_node::get, at cgraph.h:1261

2020-03-05 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79755

Andrew Pinski  changed:

   What|Removed |Added

   Keywords||ice-checking

--- Comment #11 from Andrew Pinski  ---
(In reply to Nicholas Krause from comment #8)
> test.c:1: confused by earlier errors, bailing out
> 
> So no it does not appear to segfault on 9.2 not sure about trunk.

YES it does.  Just GCC is being smart here when configured with
--enable-checking=release (the default for releases) and just prints out
"confused by earlier errors, bailing out" for all ICEs after an error has
happened.
This is why Jakub's comment #7:
"This does happen even with 9.2 and current trunk, you just need to read the
first line in #c0."
The first line in #c0 was:
Affects versions down to 4.9 (configured with --enable-checking=yes)

Which means you need --enable-checking=yes (and not --enable-checking=release)
to get the full ICE happening.

[Bug middle-end/79755] [8/9/10 Regression] ICE: segfault in cgraph_node::get, at cgraph.h:1261

2020-03-05 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79755

--- Comment #10 from Jakub Jelinek  ---
--enable-checking=release (the default on release branches) is not
--enable-checking=yes (which is needed to reproduce this checking
error-recovery failure).

[Bug middle-end/79755] [8/9/10 Regression] ICE: segfault in cgraph_node::get, at cgraph.h:1261

2020-03-05 Thread xerofoify at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79755

--- Comment #9 from Nicholas Krause  ---
Sorry source code is:
void foo () {}
#pragma weak foo = _foo
int _foo = 0;

Copy and Pasted line numbers by mistake.

[Bug middle-end/79755] [8/9/10 Regression] ICE: segfault in cgraph_node::get, at cgraph.h:1261

2020-03-05 Thread xerofoify at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79755

--- Comment #8 from Nicholas Krause  ---
(In reply to Jakub Jelinek from comment #7)
> This does happen even with 9.2 and current trunk, you just need to read the
> first line in #c0.

While I ran it as on a Ubuntu 9.2 Toolchain configured as:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.2.1-9ubuntu2'
--with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-9
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-gcc -c test.c-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib
--with-target-system-zlib=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none,hsa
--without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.2.1 20191008 (Ubuntu 9.2.1-9ubuntu2) 

like this:
gcc -c test.c

and this is my source code:
void foo () {}
  2 #pragma weak foo = _foo
  3 int _foo = 0;

and I get this:
test.c:1:6: error: ‘foo’ defined both normally and as ‘alias’ attribute
1 | void foo () {}
  |  ^~~
test.c:1:6: error: ‘foo’ alias between function and variable is not supported
test.c:3:5: note: aliased declaration here
3 | int _foo = 0;
  | ^~~~
test.c:1: confused by earlier errors, bailing out

So no it does not appear to segfault on 9.2 not sure about trunk.

[Bug middle-end/79755] [8/9/10 Regression] ICE: segfault in cgraph_node::get, at cgraph.h:1261

2020-03-05 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79755

--- Comment #7 from Jakub Jelinek  ---
This does happen even with 9.2 and current trunk, you just need to read the
first line in #c0.

[Bug middle-end/79755] [8/9/10 Regression] ICE: segfault in cgraph_node::get, at cgraph.h:1261

2020-03-05 Thread xerofoify at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79755

Nicholas Krause  changed:

   What|Removed |Added

 CC||xerofoify at gmail dot com

--- Comment #6 from Nicholas Krause  ---
Does not happen on gcc 9.2. Does the gcc 8.5 branch have these functions,  
 cgraph_function_or_thunk_node or varpool_variable_node as those were removed
on trunk and I'm suspecting that's were the problem is.

[Bug middle-end/79755] [8/9/10 Regression] ICE: segfault in cgraph_node::get, at cgraph.h:1261

2020-03-04 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79755

Jakub Jelinek  changed:

   What|Removed |Added

   Target Milestone|8.4 |8.5

--- Comment #5 from Jakub Jelinek  ---
GCC 8.4.0 has been released, adjusting target milestone.