Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

===(), ===(x) and typeassert() cause internal error when compiled #40804

Closed
Liozou opened this issue May 12, 2021 · 0 comments · Fixed by #41048
Closed

===(), ===(x) and typeassert() cause internal error when compiled #40804

Liozou opened this issue May 12, 2021 · 0 comments · Fixed by #41048
Labels
bug Indicates an unexpected problem or unintended behavior compiler:optimizer Optimization passes (mostly in base/compiler/ssair/)

Comments

@Liozou
Copy link
Member

Liozou commented May 12, 2021

This is a very minor issue since these three forms are supposed to cause an explicit error anyway, but I guess it should not cause an internal one.

julia> ===() # This works normally
ERROR: ArgumentError: ===: too few arguments (expected 2)
Stacktrace:
 [1] top-level scope
   @ REPL[38]:1

julia> foo() = ===()
foo (generic function with 1 method)

julia> foo()
Internal error: encountered unexpected error in runtime:
BoundsError(a=Array{Any, (1,)}[Main.:(===)], i=(2,))
jl_bounds_error_ints at ~/julia/src/rtutils.c:186
getindex at ./array.jl:833 [inlined]
getfield_elim_pass! at ./compiler/ssair/passes.jl:596
run_passes at ./compiler/ssair/driver.jl:133
optimize at ./compiler/optimize.jl:296 [inlined]
_typeinf at ./compiler/typeinfer.jl:255
typeinf at ./compiler/typeinfer.jl:209
typeinf_ext at ./compiler/typeinfer.jl:911
typeinf_ext_toplevel at ./compiler/typeinfer.jl:944
typeinf_ext_toplevel at ./compiler/typeinfer.jl:940
jfptr_typeinf_ext_toplevel_13423 at ~/julia/usr/lib/julia/sys.so (unknown line)
_jl_invoke at ~/julia/src/gf.c:2243 [inlined]
jl_apply_generic at ~/julia/src/gf.c:2425
jl_apply at ~/julia/src/julia.h:1760 [inlined]
jl_type_infer at ~/julia/src/gf.c:295
jl_generate_fptr at ~/julia/src/jitlayers.cpp:340
jl_compile_method_internal at ~/julia/src/gf.c:1976
jl_compile_method_internal at ~/julia/src/gf.c:1930 [inlined]
_jl_invoke at ~/julia/src/gf.c:2235 [inlined]
jl_apply_generic at ~/julia/src/gf.c:2425
jl_apply at ~/julia/src/julia.h:1760 [inlined]
do_call at ~/julia/src/interpreter.c:117
eval_value at ~/julia/src/interpreter.c:206
eval_stmt_value at ~/julia/src/interpreter.c:157 [inlined]
eval_body at ~/julia/src/interpreter.c:571
jl_interpret_toplevel_thunk at ~/julia/src/interpreter.c:718
top-level scope at REPL[2]:1
jl_toplevel_eval_flex at ~/julia/src/toplevel.c:884
jl_toplevel_eval_flex at ~/julia/src/toplevel.c:829
jl_toplevel_eval_in at ~/julia/src/toplevel.c:936
eval at ./boot.jl:369 [inlined]
eval_user_input at ~/julia/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:148
repl_backend_loop at ~/julia/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:238
start_repl_backend at ~/julia/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:223
#run_repl#45 at ~/julia/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:356
run_repl at ~/julia/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:343
_jl_invoke at ~/julia/src/gf.c:2243 [inlined]
jl_apply_generic at ~/julia/src/gf.c:2425
#894 at ./client.jl:394
jfptr_YY.894_25747 at ~/julia/usr/lib/julia/sys.so (unknown line)
_jl_invoke at ~/julia/src/gf.c:2243 [inlined]
jl_apply_generic at ~/julia/src/gf.c:2425
jl_apply at ~/julia/src/julia.h:1760 [inlined]
jl_f__call_latest at ~/julia/src/builtins.c:751
#invokelatest#2 at ./essentials.jl:726 [inlined]
invokelatest at ./essentials.jl:724 [inlined]
run_main_repl at ./client.jl:379
exec_options at ./client.jl:309
_start at ./client.jl:495
jfptr__start_31938 at ~/julia/usr/lib/julia/sys.so (unknown line)
_jl_invoke at ~/julia/src/gf.c:2243 [inlined]
jl_apply_generic at ~/julia/src/gf.c:2425
jl_apply at ~/julia/src/julia.h:1760 [inlined]
true_main at ~/julia/src/jlapi.c:540
jl_repl_entrypoint at ~/julia/src/jlapi.c:682
main at ~/julia/cli/loader_exe.c:51
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_start at /home/liozou/julia/usr/bin/julia (unknown line)
ERROR: ArgumentError: ===: too few arguments (expected 2)
Stacktrace:
 [1] foo()
   @ Main ./REPL[1]:1
 [2] top-level scope
   @ REPL[2]:1

The same happens with foo(x) = ===(x) but there is no issue when === has too many arguments. I initially found this with === but since it looked like a problem specific to builtins, I also checked the other ones (from the list of the docs here) and found that typeassert() has the same issue, while typeassert(x) does not.

I checked for this on master (1.7.0-DEV.1089, commit d6c092d). The issue is old since it is already present in julia 1.0.0. Incidentally, at the time there were similar internal errors for getfield, setfield! and _apply but those seem to have been resolved in between.

It might be good to take it into account when doing a PR for #36163, I have not checked whether #36759 solves it for ===().

@KristofferC KristofferC added the bug Indicates an unexpected problem or unintended behavior label May 12, 2021
@JeffBezanson JeffBezanson added the compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) label May 17, 2021
KristofferC pushed a commit that referenced this issue Jun 4, 2021
shirodkara pushed a commit to shirodkara/julia that referenced this issue Jun 9, 2021
staticfloat pushed a commit that referenced this issue Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior compiler:optimizer Optimization passes (mostly in base/compiler/ssair/)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants