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

Inference crash in handling of Core._apply_iterate #33768

Closed
KristofferC opened this issue Nov 5, 2019 · 4 comments · Fixed by #33832
Closed

Inference crash in handling of Core._apply_iterate #33768

KristofferC opened this issue Nov 5, 2019 · 4 comments · Fixed by #33832
Assignees
Labels
compiler:inference Type inference kind:bug Indicates an unexpected problem or unintended behavior

Comments

@KristofferC
Copy link
Sponsor Member

KristofferC commented Nov 5, 2019

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 JuliaDebug/JuliaInterpreter.jl@1c9b0dc#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

return abstract_apply(argtypes[2], argtypes[3], argtypes[4:end], vtypes, sv, max_methods)

which was quite recently added (#33356).

@JeffBezanson
Copy link
Sponsor Member

Looks like we need some argument count checks there.

@Keno
Copy link
Member

Keno commented Nov 5, 2019

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,))

@KristofferC
Copy link
Sponsor Member Author

KristofferC commented Nov 5, 2019

More realistic example: JuliaDebug/JuliaInterpreter.jl@cb6ab09#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 JuliaDebug/JuliaInterpreter.jl@cb6ab09#diff-5a8415c3db7ae789ed68bb4ef565118cR68-R70 doesn't trigger the same problem though.

@JeffBezanson JeffBezanson added the compiler:inference Type inference label Nov 5, 2019
@JeffBezanson
Copy link
Sponsor Member

Ah, I get it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:inference Type inference kind:bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants