https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99126
Bug ID: 99126
Summary: Compilation ICE trying insert trap
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: jit
Assignee: dmalcolm at gcc dot gnu.org
Reporter: akrl at gcc dot gnu.org
Target Milestone: ---
Created attachment 50205
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50205&action=edit
reproducer
Hi all,
to reproduce with the attached:
=========
$ gcc libgccjit_repro.c -lgccjit
$ ./a.out
Segmentation fault (core dumped)
=========
This is my understanding of what is going on here: we have a some
generated code that in GIMPLE is proved to dereference a null pointer
(BTW this code should be unreachable).
MEM[(struct comp_Lisp_Cons *)0B].u.s.car = _35;
>From the 'F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_0'
function.
Running pass 'isolate-paths' we try to inject a trap but
'builtin_decl_explicit (BUILT_IN_TRAP)' is returning NULL as the
builtin declaration that we should find in 'builtin_info' is never
initialized by the frontend (libgccjit). As a consequence we ICE in
'gimple_build_call'.
Here the backtrace:
#0 gimple_build_call (fn=0x0, nargs=nargs@entry=0) at ../../gcc/gimple.c:264
#1 0x00007ffff7450cf8 in insert_trap (si_p=si_p@entry=0x7fffffffde20,
op=0x7ffff5654fc0) at ../../gcc/gimple-ssa-isolate-paths.c:93
#2 0x00007ffff745302b in find_explicit_erroneous_behavior () at
../../gcc/gimple-ssa-isolate-paths.c:863
#3 gimple_ssa_isolate_erroneous_paths () at
../../gcc/gimple-ssa-isolate-paths.c:928
#4 (anonymous namespace)::pass_isolate_erroneous_paths::execute
(this=<optimized out>) at ../../gcc/gimple-ssa-isolate-paths.c:979
#5 0x00007ffff6a7fc3d in execute_one_pass (pass=0x6255a0) at
../../gcc/passes.c:2509
#6 0x00007ffff6a803a8 in execute_pass_list_1 (pass=0x6255a0) at
../../gcc/passes.c:2597
#7 0x00007ffff6a803ba in execute_pass_list_1 (pass=0x624990) at
../../gcc/passes.c:2598
#8 0x00007ffff6a80405 in execute_pass_list (fn=0x7ffff5849790, pass=<optimized
out>) at ../../gcc/passes.c:2608
#9 0x00007ffff6790428 in cgraph_node::expand (this=0x7ffff5850ca8) at
../../gcc/context.h:48
#10 0x00007ffff6791a6d in expand_all_functions () at
../../gcc/cgraphunit.c:2476
[...]
This ICE breaks Emacs bootstrap on 32bit machines configuring with
'--with-wide-int'.
A reduced reduced should be writable (manually as there's no creduce
for libgccjit) ATM I'm posting what I have from Emacs.
GCC 10 is likely to be affected too, I'll try it soon, GCC 9 is
working and does not show this bug.
Andrea