When trying to fix JuliaInterpreter.jl on Julia master I ran into the following:
Using the load_bounds_error branch where the only real change is https://github.com/JuliaDebug/JuliaInterpreter.jl/commit/1c9b0dc808a92a90cb46b5e756a44bb0b110364e#diff-5a8415c3db7ae789ed68bb4ef565118cR78-R79
Julia crashes on trying to load JuliaInterpreter with:
julia> using JuliaInterpreter, Test
[ Info: Precompiling JuliaInterpreter [aa1ae85d-cabe-5617-a682-6adf51b2e16a]
Internal error: encountered unexpected error in runtime:
BoundsError(a=Array{Any, (2,)}[
Core.Compiler.Const(val=typeof(Core._apply_iterate)(), actual=false),
Core.Compiler.Const(val="foo", actual=false)], i=(3,))
jl_bounds_error_ints at /home/kc/julia/src/rtutils.c:183
getindex at ./array.jl:758 [inlined]
abstract_call at ./compiler/abstractinterpretation.jl:646
abstract_call at ./compiler/abstractinterpretation.jl:643
abstract_eval_call at ./compiler/abstractinterpretation.jl:884
abstract_eval at ./compiler/abstractinterpretation.jl:954
Clearly the "foo" argument in the branch is bogus (I splatted something there before so the bounds error had a Vararg for the second argument but tried to minimize the diff).
The error is thrown from
which was quite recently added (https://github.com/JuliaLang/julia/pull/33356).
Looks like we need some argument count checks there.
Also:
julia> f() = Core._apply()
f (generic function with 1 method)
julia> f()
Internal error: encountered unexpected error in runtime:
BoundsError(a=Array{Any, (1,)}[Core.Compiler.Const(val=typeof(Core._apply)(), actual=false)], i=(2,))
More realistic example: https://github.com/JuliaDebug/JuliaInterpreter.jl/commit/cb6ab09621dde8e8eddb5165cf33571a2644a3c7#diff-5a8415c3db7ae789ed68bb4ef565118cR81
Error is:
julia> using JuliaInterpreter
[ Info: Precompiling JuliaInterpreter [aa1ae85d-cabe-5617-a682-6adf51b2e16a]
Internal error: encountered unexpected error in runtime:
BoundsError(a=Array{Any, (2,)}[
Core.Compiler.Const(val=typeof(Core._apply_iterate)(), actual=false),
Vararg{Any, N} where N], i=(3,))
jl_bounds_error_ints at /home/kc/julia/src/rtutils.c:183
getindex at ./array.jl:758 [inlined]
abstract_call at ./compiler/abstractinterpretation.jl:646
I don't understand why https://github.com/JuliaDebug/JuliaInterpreter.jl/commit/cb6ab09621dde8e8eddb5165cf33571a2644a3c7#diff-5a8415c3db7ae789ed68bb4ef565118cR68-R70 doesn't trigger the same problem though.
Ah, I get it now.