-
-
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
Julia gets stuck on recursive function #31572
Comments
Seems to be recursion during inference. |
@maartenvd and I also have examples, with a more elaborate and complicated codebase, where Julia takes several hours to run a function, which afterwards runs in less than a second. Recursion is also likely the culprit, though we don't have found a good way of debugging this behaviour yet. The strange thing is that, if you |
So during recursion it will widen the type when it fails, and i have added a println there. In both cases you see something kinda similar; recursion keeps widening the same types to the same types, almost as if it never really caches it's result and has to re-evaluate it... We also have recursive functions that call eachother. |
This is because we catch exceptions that happen during type inference and keep running without it (compiling un-inferred versions of functions), in case of an exception caused by an internal bug. |
I ran into this with GenericLinearAlgebra's julia> using GenericLinearAlgebra
julia> A = randn(1000,1000); A = A'A;
julia> GenericLinearAlgebra.cholRecursive!(copy(A), Val{:L})
^C^C^C^C^CWARNING: Force throwing a SIGINT
Internal error: encountered unexpected error in runtime:
InterruptException()
jl_egal at /home/chriselrod/Documents/languages/jdev/src/builtins.c:172
compare_fields at /home/chriselrod/Documents/languages/jdev/src/builtins.c:92
is_lattice_equal at ./compiler/typelattice.jl:182
is_argtype_match at ./compiler/inferenceresult.jl:21 [inlined]
cache_lookup at ./compiler/inferenceresult.jl:153
abstract_call_method_with_const_args at ./compiler/abstractinterpretation.jl:215
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:115
abstract_call at ./compiler/abstractinterpretation.jl:808
abstract_call at ./compiler/abstractinterpretation.jl:598
abstract_eval_call at ./compiler/abstractinterpretation.jl:837
^Cabstract_eval at ./compiler/abstractinterpretation.jl:907
typeinf_local at ./compiler/abstractinterpretation.jl:1164
typeinf_nocycle at ./compiler/abstractinterpretation.jl:1220
typeinf at ./compiler/typeinfer.jl:12 Followed by a flood of repetitions: bstract_call_method_with_const_args at ./compiler/abstractinterpretation.jl:222
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:115
abstract_call at ./compiler/abstractinterpretation.jl:808
abstract_call at ./compiler/abstractinterpretation.jl:598
abstract_eval_call at ./compiler/abstractinterpretation.jl:837
abstract_eval at ./compiler/abstractinterpretation.jl:907
typeinf_local at ./compiler/abstractinterpretation.jl:1164
^Ctypeinf_nocycle at ./compiler/abstractinterpretation.jl:1220
typeinf at ./compiler/typeinfer.jl:12 finally concluding with: abstract_call_method at ./compiler/abstractinterpretation.jl:369
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:92
abstract_call at ./compiler/abstractinterpretation.jl:808
abstract_call at ./compiler/abstractinterpretation.jl:598
abstract_eval_call at ./compiler/abstractinterpretation.jl:837
abstract_eval at ./compiler/abstractinterpretation.jl:907
typeinf_local at ./compiler/abstractinterpretation.jl:1164
typeinf_nocycle at ./compiler/abstractinterpretation.jl:1220
typeinf at ./compiler/typeinfer.jl:12
typeinf_edge at ./compiler/typeinfer.jl:482
abstract_call_method at ./compiler/abstractinterpretation.jl:369
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:92
abstract_call at ./compiler/abstractinterpretation.jl:808
abstract_call at ./compiler/abstractinterpretation.jl:598
abstract_eval_call at ./compiler/abstractinterpretation.jl:837
abstract_eval at ./compiler/abstractinterpretation.jl:907
typeinf_local at ./compiler/abstractinterpretation.jl:1164
typeinf_nocycle at ./compiler/abstractinterpretation.jl:1220
typeinf at ./compiler/typeinfer.jl:12
typeinf_ext at ./compiler/typeinfer.jl:568
typeinf_ext at ./compiler/typeinfer.jl:599
jfptr_typeinf_ext_1 at /home/chriselrod/Documents/languages/jdev/usr/lib/julia/sys.so (unknown line)
jl_apply_generic at /home/chriselrod/Documents/languages/jdev/src/gf.c:2191
jl_apply at /home/chriselrod/Documents/languages/jdev/src/julia.h:1604 [inlined]
jl_type_infer at /home/chriselrod/Documents/languages/jdev/src/gf.c:207
jl_compile_method_internal at /home/chriselrod/Documents/languages/jdev/src/gf.c:1773
jl_apply_generic at /home/chriselrod/Documents/languages/jdev/src/gf.c:2196
do_call at /home/chriselrod/Documents/languages/jdev/src/interpreter.c:323
eval_value at /home/chriselrod/Documents/languages/jdev/src/interpreter.c:411
eval_stmt_value at /home/chriselrod/Documents/languages/jdev/src/interpreter.c:362 [inlined]
eval_body at /home/chriselrod/Documents/languages/jdev/src/interpreter.c:758
jl_interpret_toplevel_thunk_callback at /home/chriselrod/Documents/languages/jdev/src/interpreter.c:884
Interpreter frame (ip: 3)
Core.CodeInfo(code=Array{Any, (5,)}[
Expr(:call, Base.getproperty, :GenericLinearAlgebra, :(:cholRecursive!)),
Expr(:call, :copy, :A),
Expr(:call, Core.apply_type, :Val, :(:L)),
Expr(:call, SSAValue(1), SSAValue(2), SSAValue(3)),
Expr(:return, SSAValue(4))], codelocs=Array{Int32, (5,)}[1, 1, 1, 1, 1], ssavaluetypes=5, ssaflags=Array{UInt8, (0,)}[], method_for_inference_limit_heuristics=nothing, linetable=Array{Any, (1,)}[Core.LineInfoNode(method=Symbol("top-level scope"), file=Symbol("REPL[8]"), line=1, inlined_at=0)], slotnames=Array{Symbol, (0,)}[], slotflags=Array{UInt8, (0,)}[], slottypes=nothing, rettype=Any, parent=nothing, min_world=1, max_world=-1, inferred=false, inlineable=false, propagate_inbounds=false, pure=false)jl_interpret_toplevel_thunk at /home/chriselrod/Documents/languages/jdev/src/interpreter.c:893
jl_toplevel_eval_flex at /home/chriselrod/Documents/languages/jdev/src/toplevel.c:797
jl_toplevel_eval_flex at /home/chriselrod/Documents/languages/jdev/src/toplevel.c:746
jl_toplevel_eval_flex at /home/chriselrod/Documents/languages/jdev/src/toplevel.c:746
jl_toplevel_eval_in at /home/chriselrod/Documents/languages/jdev/src/toplevel.c:826
eval at ./boot.jl:330
jl_apply_generic at /home/chriselrod/Documents/languages/jdev/src/gf.c:2191
eval_user_input at /home/chriselrod/Documents/languages/jdev/usr/share/julia/stdlib/v1.3/REPL/src/REPL.jl:86
macro expansion at /home/chriselrod/Documents/languages/jdev/usr/share/julia/stdlib/v1.3/REPL/src/REPL.jl:118 [inlined]
#26 at ./task.jl:268
jl_apply_generic at /home/chriselrod/Documents/languages/jdev/src/gf.c:2191
jl_apply at /home/chriselrod/Documents/languages/jdev/src/julia.h:1604 [inlined]
start_task at /home/chriselrod/Documents/languages/jdev/src/task.c:583
unknown function (ip: 0xffffffffffffffff) and then suddenly display the result. Rerunning showed the results immediately. |
when we hit union-splitting, we need to ensure type limits are very aggressive and preferably also independent of the height of the recursion chain fix #31572
when we hit union-splitting, we need to ensure type limits are very aggressive and preferably also independent of the height of the recursion chain fix #31572
when we hit union-splitting, we need to ensure type limits are very aggressive and preferably also independent of the height of the recursion chain fix #31572
when we hit union-splitting, we need to ensure type limits are very aggressive and preferably also independent of the height of the recursion chain fix #31572
I have already posted this on discourse and since this definitely seems to be a bug, I'm opening an issue.
I defined the following
merge
function for a customDict
type:For two dicts, this works perfectly well:
But as soon as I add another one, Julia gets completely stuck and I have to kill the whole process.
I thought there might be a bug in my code, so I tried debugging it with
Debugger.jl
, but the weird part is,that it works just fine if I just@enter
the function and let it continue without any breakpoints set:If I tell
Debugger.jl
to use the compiled mode, it gets stuck again. This seems to be a bug in the compiler. If I call the underlying_merge
-function directly, I get the same behavior, although calling_alloftype
directly runs fine. @KristofferC suggested, it might be bug in the way Julia tries to optimize this code.My Julia version:
I've also tried it with the latest nightly, but no luck there either.
The text was updated successfully, but these errors were encountered: