public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug jit/99126] New: Compilation ICE trying insert trap
@ 2021-02-16 19:42 akrl at gcc dot gnu.org
2021-02-16 20:26 ` Andrea Corallo
` (9 more replies)
0 siblings, 10 replies; 13+ messages in thread
From: akrl at gcc dot gnu.org @ 2021-02-16 19:42 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Bug jit/99126] New: Compilation ICE trying insert trap
2021-02-16 19:42 [Bug jit/99126] New: Compilation ICE trying insert trap akrl at gcc dot gnu.org
@ 2021-02-16 20:26 ` Andrea Corallo
2021-02-16 20:26 ` [Bug jit/99126] " andrea.corallo at arm dot com
` (8 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Andrea Corallo @ 2021-02-16 20:26 UTC (permalink / raw)
To: akrl at gcc dot gnu.org via Gcc-bugs; +Cc: akrl at gcc dot gnu.org
This is the bt of how the C front-end is initializing these
declarations:
#0 set_builtin_decl (implicit_p=<optimized out>,
decl=<function_decl 0x7ffff72a0800 __builtin_return_address>,
fncode=<optimized out>) at ../../gcc/tree.h:5662
#1 def_builtin_1 (fncode=<optimized out>, name=<optimized out>,
fntype=<optimized out>, libtype=<tree 0x0>, both_p=<optimized out>,
fallback_p=<optimized out>, nonansi_p=false,
fnattrs=<tree_list 0x7ffff7204f78>, implicit_p=true, fnclass=BUILT_IN_NORMAL)
at ../../gcc/c-family/c-common.c:4729
#2 0x0000000000a291c9 in c_define_builtins (
va_list_arg_type_node=<optimized out>, va_list_ref_type_node=<optimized out>)
at ../../gcc/builtins.def:933
Thinking loud: I guess in jit-builtins.c we should loop once over all
the builtins calling 'set_builtin_decl'? Probably in the constructor
for gcc::jit::builtins_manager?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug jit/99126] Compilation ICE trying insert trap
2021-02-16 19:42 [Bug jit/99126] New: Compilation ICE trying insert trap akrl at gcc dot gnu.org
2021-02-16 20:26 ` Andrea Corallo
@ 2021-02-16 20:26 ` andrea.corallo at arm dot com
2021-02-17 8:18 ` marxin at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: andrea.corallo at arm dot com @ 2021-02-16 20:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99126
--- Comment #1 from Andrea Corallo <andrea.corallo at arm dot com> ---
This is the bt of how the C front-end is initializing these
declarations:
#0 set_builtin_decl (implicit_p=<optimized out>,
decl=<function_decl 0x7ffff72a0800 __builtin_return_address>,
fncode=<optimized out>) at ../../gcc/tree.h:5662
#1 def_builtin_1 (fncode=<optimized out>, name=<optimized out>,
fntype=<optimized out>, libtype=<tree 0x0>, both_p=<optimized out>,
fallback_p=<optimized out>, nonansi_p=false,
fnattrs=<tree_list 0x7ffff7204f78>, implicit_p=true,
fnclass=BUILT_IN_NORMAL)
at ../../gcc/c-family/c-common.c:4729
#2 0x0000000000a291c9 in c_define_builtins (
va_list_arg_type_node=<optimized out>, va_list_ref_type_node=<optimized
out>)
at ../../gcc/builtins.def:933
Thinking loud: I guess in jit-builtins.c we should loop once over all
the builtins calling 'set_builtin_decl'? Probably in the constructor
for gcc::jit::builtins_manager?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug jit/99126] Compilation ICE trying insert trap
2021-02-16 19:42 [Bug jit/99126] New: Compilation ICE trying insert trap akrl at gcc dot gnu.org
2021-02-16 20:26 ` Andrea Corallo
2021-02-16 20:26 ` [Bug jit/99126] " andrea.corallo at arm dot com
@ 2021-02-17 8:18 ` marxin at gcc dot gnu.org
2021-02-18 0:07 ` dmalcolm at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-02-17 8:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99126
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-02-17
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
CC| |marxin at gcc dot gnu.org
--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Thanks for the report.
> 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).
That's fine.
>
> MEM[(struct comp_Lisp_Cons *)0B].u.s.car = _35;
>
So I guess JIT should really initialize the builtins.
I tried manually calling:
gcc_jit_context_get_builtin_function (ctxt_0x8892590, "__builtin_trap");
and then your reproducer is fine.
Leaving to David.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug jit/99126] Compilation ICE trying insert trap
2021-02-16 19:42 [Bug jit/99126] New: Compilation ICE trying insert trap akrl at gcc dot gnu.org
` (2 preceding siblings ...)
2021-02-17 8:18 ` marxin at gcc dot gnu.org
@ 2021-02-18 0:07 ` dmalcolm at gcc dot gnu.org
2021-02-18 21:07 ` dmalcolm at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2021-02-18 0:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99126
--- Comment #3 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Created attachment 50216
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50216&action=edit
Minimal reproducer as a test case
Attached is a minimal reproducer, as a test case. I don't have a fix for this
yet.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug jit/99126] Compilation ICE trying insert trap
2021-02-16 19:42 [Bug jit/99126] New: Compilation ICE trying insert trap akrl at gcc dot gnu.org
` (3 preceding siblings ...)
2021-02-18 0:07 ` dmalcolm at gcc dot gnu.org
@ 2021-02-18 21:07 ` dmalcolm at gcc dot gnu.org
2021-02-18 21:19 ` Andrea Corallo
2021-02-18 21:19 ` andrea.corallo at arm dot com
` (4 subsequent siblings)
9 siblings, 1 reply; 13+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2021-02-18 21:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99126
David Malcolm <dmalcolm at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
--- Comment #4 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Am testing a fix.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Bug jit/99126] Compilation ICE trying insert trap
2021-02-18 21:07 ` dmalcolm at gcc dot gnu.org
@ 2021-02-18 21:19 ` Andrea Corallo
0 siblings, 0 replies; 13+ messages in thread
From: Andrea Corallo @ 2021-02-18 21:19 UTC (permalink / raw)
To: dmalcolm at gcc dot gnu.org via Gcc-bugs; +Cc: dmalcolm at gcc dot gnu.org
"dmalcolm at gcc dot gnu.org via Gcc-bugs" <gcc-bugs@gcc.gnu.org>
writes:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99126
>
> David Malcolm <dmalcolm at gcc dot gnu.org> changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> Status|NEW |ASSIGNED
>
> --- Comment #4 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
> Am testing a fix.
Nice!
As a side question: do you guys think disabling "isolate-paths" is the
right workaround for the affected versions or might have harmful side
effects?
Thanks
Andrea
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug jit/99126] Compilation ICE trying insert trap
2021-02-16 19:42 [Bug jit/99126] New: Compilation ICE trying insert trap akrl at gcc dot gnu.org
` (4 preceding siblings ...)
2021-02-18 21:07 ` dmalcolm at gcc dot gnu.org
@ 2021-02-18 21:19 ` andrea.corallo at arm dot com
2021-02-19 2:29 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: andrea.corallo at arm dot com @ 2021-02-18 21:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99126
--- Comment #5 from Andrea Corallo <andrea.corallo at arm dot com> ---
"dmalcolm at gcc dot gnu.org via Gcc-bugs" <gcc-bugs@gcc.gnu.org>
writes:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99126
>
> David Malcolm <dmalcolm at gcc dot gnu.org> changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> Status|NEW |ASSIGNED
>
> --- Comment #4 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
> Am testing a fix.
Nice!
As a side question: do you guys think disabling "isolate-paths" is the
right workaround for the affected versions or might have harmful side
effects?
Thanks
Andrea
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug jit/99126] Compilation ICE trying insert trap
2021-02-16 19:42 [Bug jit/99126] New: Compilation ICE trying insert trap akrl at gcc dot gnu.org
` (5 preceding siblings ...)
2021-02-18 21:19 ` andrea.corallo at arm dot com
@ 2021-02-19 2:29 ` cvs-commit at gcc dot gnu.org
2021-02-19 2:34 ` dmalcolm at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-19 2:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99126
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:
https://gcc.gnu.org/g:b258e263e0d74ca1f76aeaac5f4d1abef6b13707
commit r11-7288-gb258e263e0d74ca1f76aeaac5f4d1abef6b13707
Author: David Malcolm <dmalcolm@redhat.com>
Date: Thu Feb 18 21:28:26 2021 -0500
jit: fix ICE on BUILT_IN_TRAP [PR99126]
gcc/jit/ChangeLog:
PR jit/99126
* jit-builtins.c
(gcc::jit::builtins_manager::get_builtin_function_by_id):
Update assertion to reject BUILT_IN_NONE.
(gcc::jit::builtins_manager::ensure_optimization_builtins_exist):
New.
* jit-builtins.h
(gcc::jit::builtins_manager::ensure_optimization_builtins_exist):
New decl.
* jit-playback.c (gcc::jit::playback::context::replay): Call it.
Remove redundant conditional on bm.
gcc/testsuite/ChangeLog:
PR jit/99126
* jit.dg/test-trap.c: New test.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug jit/99126] Compilation ICE trying insert trap
2021-02-16 19:42 [Bug jit/99126] New: Compilation ICE trying insert trap akrl at gcc dot gnu.org
` (6 preceding siblings ...)
2021-02-19 2:29 ` cvs-commit at gcc dot gnu.org
@ 2021-02-19 2:34 ` dmalcolm at gcc dot gnu.org
2021-02-19 2:35 ` dmalcolm at gcc dot gnu.org
2021-02-22 13:29 ` andrea.corallo at arm dot com
9 siblings, 0 replies; 13+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2021-02-19 2:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99126
--- Comment #7 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
(In reply to Andrea Corallo from comment #5)
> As a side question: do you guys think disabling "isolate-paths" is the
> right workaround for the affected versions or might have harmful side
> effects?
It ought to stop the crash; given that the code path happens on places where
the compiler predicts a NULL dereference, I don't think it can cause additional
problems.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug jit/99126] Compilation ICE trying insert trap
2021-02-16 19:42 [Bug jit/99126] New: Compilation ICE trying insert trap akrl at gcc dot gnu.org
` (7 preceding siblings ...)
2021-02-19 2:34 ` dmalcolm at gcc dot gnu.org
@ 2021-02-19 2:35 ` dmalcolm at gcc dot gnu.org
2021-02-22 13:29 ` Andrea Corallo
2021-02-22 13:29 ` andrea.corallo at arm dot com
9 siblings, 1 reply; 13+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2021-02-19 2:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99126
--- Comment #8 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
(In reply to CVS Commits from comment #6)
> The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:
>
> https://gcc.gnu.org/g:b258e263e0d74ca1f76aeaac5f4d1abef6b13707
>
> commit r11-7288-gb258e263e0d74ca1f76aeaac5f4d1abef6b13707
Fixed on trunk for gcc 11. Andrea, do you need my to backport this? What GCC
versions are you targeting with your emacs project?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Bug jit/99126] Compilation ICE trying insert trap
2021-02-19 2:35 ` dmalcolm at gcc dot gnu.org
@ 2021-02-22 13:29 ` Andrea Corallo
0 siblings, 0 replies; 13+ messages in thread
From: Andrea Corallo @ 2021-02-22 13:29 UTC (permalink / raw)
To: dmalcolm at gcc dot gnu.org via Gcc-bugs; +Cc: dmalcolm at gcc dot gnu.org, nd
"dmalcolm at gcc dot gnu.org via Gcc-bugs" <gcc-bugs@gcc.gnu.org>
writes:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99126
>
> --- Comment #8 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
> (In reply to CVS Commits from comment #6)
>> The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:
>>
>> https://gcc.gnu.org/g:b258e263e0d74ca1f76aeaac5f4d1abef6b13707
>>
>> commit r11-7288-gb258e263e0d74ca1f76aeaac5f4d1abef6b13707
>
> Fixed on trunk for gcc 11. Andrea, do you need my to backport this? What GCC
> versions are you targeting with your emacs project?
We are targetting them all, but to my test I could not trigger this bug
on GCC9 so I guess we could backport on GCC10 only?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug jit/99126] Compilation ICE trying insert trap
2021-02-16 19:42 [Bug jit/99126] New: Compilation ICE trying insert trap akrl at gcc dot gnu.org
` (8 preceding siblings ...)
2021-02-19 2:35 ` dmalcolm at gcc dot gnu.org
@ 2021-02-22 13:29 ` andrea.corallo at arm dot com
9 siblings, 0 replies; 13+ messages in thread
From: andrea.corallo at arm dot com @ 2021-02-22 13:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99126
--- Comment #9 from Andrea Corallo <andrea.corallo at arm dot com> ---
"dmalcolm at gcc dot gnu.org via Gcc-bugs" <gcc-bugs@gcc.gnu.org>
writes:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99126
>
> --- Comment #8 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
> (In reply to CVS Commits from comment #6)
>> The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:
>>
>> https://gcc.gnu.org/g:b258e263e0d74ca1f76aeaac5f4d1abef6b13707
>>
>> commit r11-7288-gb258e263e0d74ca1f76aeaac5f4d1abef6b13707
>
> Fixed on trunk for gcc 11. Andrea, do you need my to backport this? What GCC
> versions are you targeting with your emacs project?
We are targetting them all, but to my test I could not trigger this bug
on GCC9 so I guess we could backport on GCC10 only?
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2021-02-22 13:29 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-16 19:42 [Bug jit/99126] New: Compilation ICE trying insert trap akrl at gcc dot gnu.org
2021-02-16 20:26 ` Andrea Corallo
2021-02-16 20:26 ` [Bug jit/99126] " andrea.corallo at arm dot com
2021-02-17 8:18 ` marxin at gcc dot gnu.org
2021-02-18 0:07 ` dmalcolm at gcc dot gnu.org
2021-02-18 21:07 ` dmalcolm at gcc dot gnu.org
2021-02-18 21:19 ` Andrea Corallo
2021-02-18 21:19 ` andrea.corallo at arm dot com
2021-02-19 2:29 ` cvs-commit at gcc dot gnu.org
2021-02-19 2:34 ` dmalcolm at gcc dot gnu.org
2021-02-19 2:35 ` dmalcolm at gcc dot gnu.org
2021-02-22 13:29 ` Andrea Corallo
2021-02-22 13:29 ` andrea.corallo at arm dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).