-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Mistaken inference error on first call #21369
Comments
Even simpler repro: julia> function breaks()
try
error("ohoh")
catch
warn(STDERR, "this didn't work")
rethrow()
end
end
breaks (generic function with 1 method)
julia> breaks()
WARNING: this didn't work
ERROR: TypeError: Dense: in T, expected T<:Union{Complex{Float64}, Float64}, got Type{StackFrame}
Stacktrace:
[1] _methods_by_ftype(::Any, ::Int64, ::UInt64, ::Array{UInt64,1}, ::Array{UInt64,1}) at ./reflection.jl:521
[2] abstract_call_gf_by_type(::Any, ::Any, ::Core.Inference.InferenceState) at ./inference.jl:1267
[3] abstract_call(::Any, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}, ::Core.Inference.InferenceState) at ./inference.jl:1864
[4] abstract_eval_call(::Expr, ::Array{Any,1}, ::Core.Inference.InferenceState) at ./inference.jl:1894
[5] abstract_eval(::Any, ::Array{Any,1}, ::Core.Inference.InferenceState) at ./inference.jl:1917
[6] copy!(::Array{Any,1}, ::Core.Inference.Generator{Array{Any,1},Core.Inference.##187#188{Array{Any,1},Core.Inference.InferenceState}}) at ./abstractarray.jl:565
[7] abstract_eval_call(::Expr, ::Array{Any,1}, ::Core.Inference.InferenceState) at ./inference.jl:1868
[8] abstract_eval(::Any, ::Array{Any,1}, ::Core.Inference.InferenceState) at ./inference.jl:1917
[9] abstract_interpret(::Any, ::Array{Any,1}, ::Core.Inference.InferenceState) at ./inference.jl:2040
[10] typeinf_frame(::Core.Inference.InferenceState) at ./inference.jl:2704
[11] typeinf_loop(::Core.Inference.InferenceState) at ./inference.jl:2603
[12] typeinf_frame(::Core.MethodInstance, ::Core.Inference.InferenceState, ::Bool, ::Bool, ::Core.Inference.InferenceParams) at ./inference.jl:2473
[13] typeinf_edge(::Method, ::Any, ::SimpleVector, ::Core.Inference.InferenceState) at ./inference.jl:2496
[14] abstract_call_gf_by_type(::Any, ::Any, ::Core.Inference.InferenceState) at ./inference.jl:1386
[15] abstract_call(::Any, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}, ::Core.Inference.InferenceState) at ./inference.jl:1864
[16] abstract_eval_call(::Expr, ::Array{Any,1}, ::Core.Inference.InferenceState) at ./inference.jl:1894
[17] abstract_eval(::Any, ::Array{Any,1}, ::Core.Inference.InferenceState) at ./inference.jl:1917
[18] typeinf_frame(::Core.Inference.InferenceState) at ./inference.jl:2757
[19] typeinf_loop(::Core.Inference.InferenceState) at ./inference.jl:2603
[20] typeinf_frame(::Core.MethodInstance, ::Core.Inference.InferenceState, ::Bool, ::Bool, ::Core.Inference.InferenceParams) at ./inference.jl:2473
[21] typeinf_edge(::Method, ::Any, ::SimpleVector, ::Core.Inference.InferenceState) at ./inference.jl:2496
[22] abstract_call_gf_by_type(::Any, ::Any, ::Core.Inference.InferenceState) at ./inference.jl:1386
[23] abstract_call(::Any, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}, ::Core.Inference.InferenceState) at ./inference.jl:1864
[24] abstract_eval_call(::Expr, ::Array{Any,1}, ::Core.Inference.InferenceState) at ./inference.jl:1894
[25] abstract_eval(::Any, ::Array{Any,1}, ::Core.Inference.InferenceState) at ./inference.jl:1917
[26] abstract_interpret(::Any, ::Array{Any,1}, ::Core.Inference.InferenceState) at ./inference.jl:2040
[27] typeinf_frame(::Core.Inference.InferenceState) at ./inference.jl:2704
[28] typeinf_loop(::Core.Inference.InferenceState) at ./inference.jl:2603
[29] typeinf_frame(::Core.MethodInstance, ::Core.Inference.InferenceState, ::Bool, ::Bool, ::Core.Inference.InferenceParams) at ./inference.jl:2473
[30] typeinf_edge(::Method, ::Any, ::SimpleVector, ::Core.Inference.InferenceState) at ./inference.jl:2496
[31] abstract_call_gf_by_type(::Any, ::Any, ::Core.Inference.InferenceState) at ./inference.jl:1386
[32] abstract_call(::Any, ::Tuple{}, ::Array{Any,1}, ::Array{Any,1}, ::Core.Inference.InferenceState) at ./inference.jl:1864
[33] abstract_apply(::Any, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}, ::Core.Inference.InferenceState) at ./inference.jl:1516
[34] abstract_call(::Any, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}, ::Core.Inference.InferenceState) at ./inference.jl:1648
[35] abstract_eval_call(::Expr, ::Array{Any,1}, ::Core.Inference.InferenceState) at ./inference.jl:1894
[36] abstract_eval(::Any, ::Array{Any,1}, ::Core.Inference.InferenceState) at ./inference.jl:1917
[37] typeinf_frame(::Core.Inference.InferenceState) at ./inference.jl:2757
[38] typeinf_loop(::Core.Inference.InferenceState) at ./inference.jl:2620
[39] typeinf_frame(::Core.MethodInstance, ::Void, ::Bool, ::Bool, ::Core.Inference.InferenceParams) at ./inference.jl:2473
[40] typeinf_code(::Core.MethodInstance, ::Bool, ::Bool, ::Core.Inference.InferenceParams) at ./inference.jl:2543
[41] typeinf_ext(::Core.MethodInstance, ::UInt64) at ./inference.jl:2582
[42] breaks() at ./REPL[1]:5 BUT (in a fresh session): julia> function breaks()
try
error("ohoh")
catch
warn(STDERR, "this didn't work")
rethrow()
end
end
breaks (generic function with 1 method)
julia> warn(STDERR, "this didn't work")
WARNING: this didn't work
julia> breaks()
WARNING: this didn't work
ERROR: ohoh
Stacktrace:
[1] breaks() at ./REPL[0]:3 Also (fresh session again): julia> warn(STDERR, "this didn't work")
WARNING: this didn't work
julia> rethrow()
ERROR: TypeError: Dense: in T, expected T<:Union{Complex{Float64}, Float64}, got Type{StackFrame} So I guess this is #19979 and for some reason there is an exception thrown and caught inside the type inference of |
Yes, these internal exceptions are pretty annoying. Maybe finally time to tackle it. What's happening is that we often need to try instantiating types, and only find out that the instantiation is invalid by catching the type error that's thrown. For example this case is intersecting:
which overlap if, perversely, we have a |
I think that's one facet of it. I think the solution here is that we should save/restore the error/backtrace across calls to compilation / type-inference in |
Yes, that would be good. Even easier, we could disable collection of backtraces in those contexts, which would save the compiler some time too. |
fix #21369, exception state overwritten by caught internal errors
Distilled from ImageMagick.jl:
Upon usage:
The text was updated successfully, but these errors were encountered: