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

Stack overflow in inference #627

Open
Drvi opened this issue Apr 27, 2024 · 1 comment
Open

Stack overflow in inference #627

Drvi opened this issue Apr 27, 2024 · 1 comment

Comments

@Drvi
Copy link

Drvi commented Apr 27, 2024

We saw the following stack overflow in our tests, using JET v0.8.21 using Julia 1.10.2 using

analyze_from_definitions=true,
concretization_patterns = [:(x_)],
target_defined_modules=false,
mode=:typo
  StackOverflowError:
  Stacktrace:
      [1] typeinf_local(interp::JET.JETAnalyzer{JET.TypoPass}, frame::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:2939
      [2] typeinf_nocycle(interp::JET.JETAnalyzer{JET.TypoPass}, frame::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:3186
      [3] _typeinf(analyzer::JET.JETAnalyzer{JET.TypoPass}, frame::Core.Compiler.InferenceState)
        @ JET ~/.julia/packages/JET/lopE4/src/abstractinterpret/typeinfer.jl:509
      [4] typeinf(interp::JET.JETAnalyzer{JET.TypoPass}, frame::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/typeinfer.jl:219
      [5] typeinf(analyzer::JET.JETAnalyzer{JET.TypoPass}, frame::Core.Compiler.InferenceState)
        @ JET ~/.julia/packages/JET/lopE4/src/abstractinterpret/typeinfer.jl:405
      [6] typeinf_edge(interp::JET.JETAnalyzer{JET.TypoPass}, method::Method, atype::Any, sparams::Core.SimpleVector, caller::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/typeinfer.jl:930
      [7] typeinf_edge
        @ ~/.julia/packages/JET/lopE4/src/abstractinterpret/typeinfer.jl:211 [inlined]
      [8] abstract_call_method(interp::JET.JETAnalyzer{JET.TypoPass}, method::Method, sig::Any, sparams::Core.SimpleVector, hardlimit::Bool, si::Core.Compiler.StmtInfo, sv::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:629
      [9] abstract_call_method
        @ ~/.julia/packages/JET/lopE4/src/abstractinterpret/typeinfer.jl:19 [inlined]
     [10] abstract_call_gf_by_type(interp::JET.JETAnalyzer{JET.TypoPass}, f::Any, arginfo::Core.Compiler.ArgInfo, si::Core.Compiler.StmtInfo, atype::Any, sv::Core.Compiler.InferenceState, max_methods::Int64)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:95
     [11] abstract_call_gf_by_type
        @ ~/.julia/packages/JET/lopE4/src/analyzers/jetanalyzer.jl:284 [inlined]
     [12] abstract_call_known(interp::JET.JETAnalyzer{JET.TypoPass}, f::Any, arginfo::Core.Compiler.ArgInfo, si::Core.Compiler.StmtInfo, sv::Core.Compiler.InferenceState, max_methods::Int64)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:2087
     [13] abstract_call_known(analyzer::JET.JETAnalyzer{JET.TypoPass}, f::Any, arginfo::Core.Compiler.ArgInfo, si::Core.Compiler.StmtInfo, sv::Core.Compiler.InferenceState, max_methods::Int64)
        @ JET ~/.julia/packages/JET/lopE4/src/abstractinterpret/typeinfer.jl:100
     [14] abstract_call(interp::JET.JETAnalyzer{JET.TypoPass}, arginfo::Core.Compiler.ArgInfo, si::Core.Compiler.StmtInfo, sv::Core.Compiler.InferenceState, max_methods::Int64)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:2169
     [15] abstract_apply(interp::JET.JETAnalyzer{JET.TypoPass}, argtypes::Vector{Any}, si::Core.Compiler.StmtInfo, sv::Core.Compiler.InferenceState, max_methods::Int64)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:1612
     [16] abstract_call_known(interp::JET.JETAnalyzer{JET.TypoPass}, f::Any, arginfo::Core.Compiler.ArgInfo, si::Core.Compiler.StmtInfo, sv::Core.Compiler.InferenceState, max_methods::Int64)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:2004
     [17] abstract_call_known(analyzer::JET.JETAnalyzer{JET.TypoPass}, f::Any, arginfo::Core.Compiler.ArgInfo, si::Core.Compiler.StmtInfo, sv::Core.Compiler.InferenceState, max_methods::Int64)
        @ JET ~/.julia/packages/JET/lopE4/src/abstractinterpret/typeinfer.jl:100
     [18] abstract_call(interp::JET.JETAnalyzer{JET.TypoPass}, arginfo::Core.Compiler.ArgInfo, si::Core.Compiler.StmtInfo, sv::Core.Compiler.InferenceState, max_methods::Int64)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:2169
     [19] abstract_call(interp::JET.JETAnalyzer{JET.TypoPass}, arginfo::Core.Compiler.ArgInfo, si::Core.Compiler.StmtInfo, sv::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:2162
     [20] abstract_call(interp::JET.JETAnalyzer{JET.TypoPass}, arginfo::Core.Compiler.ArgInfo, sv::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:2354
     [21] abstract_eval_call(interp::JET.JETAnalyzer{JET.TypoPass}, e::Expr, vtypes::Vector{Core.Compiler.VarState}, sv::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:2370
     [22] abstract_eval_statement_expr(interp::JET.JETAnalyzer{JET.TypoPass}, e::Expr, vtypes::Vector{Core.Compiler.VarState}, sv::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:2380
     [23] abstract_eval_statement(interp::JET.JETAnalyzer{JET.TypoPass}, e::Any, vtypes::Vector{Core.Compiler.VarState}, sv::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:2624
     [24] abstract_eval_statement(analyzer::JET.JETAnalyzer{JET.TypoPass}, e::Any, vtypes::Vector{Core.Compiler.VarState}, sv::Core.Compiler.InferenceState)
        @ JET ~/.julia/packages/JET/lopE4/src/abstractinterpret/typeinfer.jl:672
     [25] abstract_eval_basic_statement(interp::JET.JETAnalyzer{JET.TypoPass}, stmt::Any, pc_vartable::Vector{Core.Compiler.VarState}, frame::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:2913
     [26] abstract_eval_basic_statement(analyzer::JET.JETAnalyzer{JET.TypoPass}, stmt::Any, pc_vartable::Vector{Core.Compiler.VarState}, frame::Core.Compiler.InferenceState)
        @ JET ~/.julia/packages/JET/lopE4/src/analyzers/jetanalyzer.jl:458
     [27] typeinf_local(interp::JET.JETAnalyzer{JET.TypoPass}, frame::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:3098
  --- the last 26 lines are repeated 93 more times ---
   [2446] typeinf_nocycle(interp::JET.JETAnalyzer{JET.TypoPass}, frame::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:3186
   [2447] _typeinf(analyzer::JET.JETAnalyzer{JET.TypoPass}, frame::Core.Compiler.InferenceState)
        @ JET ~/.julia/packages/JET/lopE4/src/abstractinterpret/typeinfer.jl:509
   [2448] typeinf(interp::JET.JETAnalyzer{JET.TypoPass}, frame::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/typeinfer.jl:219
   [2449] typeinf(analyzer::JET.JETAnalyzer{JET.TypoPass}, frame::Core.Compiler.InferenceState)
        @ JET ~/.julia/packages/JET/lopE4/src/abstractinterpret/typeinfer.jl:405
   [2450] typeinf_edge(interp::JET.JETAnalyzer{JET.TypoPass}, method::Method, atype::Any, sparams::Core.SimpleVector, caller::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/typeinfer.jl:930
   [2451] typeinf_edge
        @ ~/.julia/packages/JET/lopE4/src/abstractinterpret/typeinfer.jl:211 [inlined]
   [2452] abstract_call_method(interp::JET.JETAnalyzer{JET.TypoPass}, method::Method, sig::Any, sparams::Core.SimpleVector, hardlimit::Bool, si::Core.Compiler.StmtInfo, sv::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:629
   [2453] abstract_call_method
        @ ~/.julia/packages/JET/lopE4/src/abstractinterpret/typeinfer.jl:19 [inlined]
   [2454] abstract_call_gf_by_type(interp::JET.JETAnalyzer{JET.TypoPass}, f::Any, arginfo::Core.Compiler.ArgInfo, si::Core.Compiler.StmtInfo, atype::Any, sv::Core.Compiler.InferenceState, max_methods::Int64)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:95
   [2455] abstract_call_gf_by_type
        @ ~/.julia/packages/JET/lopE4/src/analyzers/jetanalyzer.jl:284 [inlined]
   [2456] abstract_call_known(interp::JET.JETAnalyzer{JET.TypoPass}, f::Any, arginfo::Core.Compiler.ArgInfo, si::Core.Compiler.StmtInfo, sv::Core.Compiler.InferenceState, max_methods::Int64)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:2087
   [2457] abstract_call_known(analyzer::JET.JETAnalyzer{JET.TypoPass}, f::Any, arginfo::Core.Compiler.ArgInfo, si::Core.Compiler.StmtInfo, sv::Core.Compiler.InferenceState, max_methods::Int64)
        @ JET ~/.julia/packages/JET/lopE4/src/abstractinterpret/typeinfer.jl:100
   [2458] abstract_call(interp::JET.JETAnalyzer{JET.TypoPass}, arginfo::Core.Compiler.ArgInfo, si::Core.Compiler.StmtInfo, sv::Core.Compiler.InferenceState, max_methods::Int64)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:2169
   [2459] abstract_call(interp::JET.JETAnalyzer{JET.TypoPass}, arginfo::Core.Compiler.ArgInfo, si::Core.Compiler.StmtInfo, sv::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:2162
   [2460] abstract_call(interp::JET.JETAnalyzer{JET.TypoPass}, arginfo::Core.Compiler.ArgInfo, sv::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:2354
   [2461] abstract_eval_call(interp::JET.JETAnalyzer{JET.TypoPass}, e::Expr, vtypes::Vector{Core.Compiler.VarState}, sv::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:2370
   [2462] abstract_eval_statement_expr(interp::JET.JETAnalyzer{JET.TypoPass}, e::Expr, vtypes::Vector{Core.Compiler.VarState}, sv::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:2380
   [2463] abstract_eval_statement(interp::JET.JETAnalyzer{JET.TypoPass}, e::Any, vtypes::Vector{Core.Compiler.VarState}, sv::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:2624
   [2464] abstract_eval_statement(analyzer::JET.JETAnalyzer{JET.TypoPass}, e::Any, vtypes::Vector{Core.Compiler.VarState}, sv::Core.Compiler.InferenceState)
        @ JET ~/.julia/packages/JET/lopE4/src/abstractinterpret/typeinfer.jl:672
   [2465] abstract_eval_basic_statement(interp::JET.JETAnalyzer{JET.TypoPass}, stmt::Any, pc_vartable::Vector{Core.Compiler.VarState}, frame::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:2913
   [2466] abstract_eval_basic_statement(analyzer::JET.JETAnalyzer{JET.TypoPass}, stmt::Any, pc_vartable::Vector{Core.Compiler.VarState}, frame::Core.Compiler.InferenceState)
        @ JET ~/.julia/packages/JET/lopE4/src/analyzers/jetanalyzer.jl:458
   [2467] typeinf_local(interp::JET.JETAnalyzer{JET.TypoPass}, frame::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:3098
  --- the last 22 lines are repeated 11 more times ---
   [2710] typeinf_nocycle(interp::JET.JETAnalyzer{JET.TypoPass}, frame::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/abstractinterpretation.jl:3186
   [2711] _typeinf(analyzer::JET.JETAnalyzer{JET.TypoPass}, frame::Core.Compiler.InferenceState)
        @ JET ~/.julia/packages/JET/lopE4/src/abstractinterpret/typeinfer.jl:509
   [2712] typeinf(interp::JET.JETAnalyzer{JET.TypoPass}, frame::Core.Compiler.InferenceState)
        @ Core.Compiler ./compiler/typeinfer.jl:219
   [2713] typeinf(analyzer::JET.JETAnalyzer{JET.TypoPass}, frame::Core.Compiler.InferenceState)
        @ JET ~/.julia/packages/JET/lopE4/src/abstractinterpret/typeinfer.jl:405
   [2714] analyze_frame!
        @ ~/.julia/packages/JET/lopE4/src/JET.jl:771 [inlined]
   [2715] analyze_method_instance!(analyzer::JET.JETAnalyzer{JET.TypoPass}, mi::Core.MethodInstance)
        @ JET ~/.julia/packages/JET/lopE4/src/JET.jl:754
   [2716] analyze_method_signature!(analyzer::JET.JETAnalyzer{JET.TypoPass}, m::Method, atype::Any, sparams::Core.SimpleVector)
        @ JET ~/.julia/packages/JET/lopE4/src/JET.jl:744
   [2717] analyze_from_definitions!(analyzer::JET.JETAnalyzer{JET.TypoPass}, res::JET.VirtualProcessResult, config::JET.ToplevelConfig)
        @ JET ~/.julia/packages/JET/lopE4/src/toplevel/virtualprocess.jl:545
   [2718] virtual_process(x::String, filename::String, analyzer::JET.JETAnalyzer{JET.TypoPass}, config::JET.ToplevelConfig)
        @ JET ~/.julia/packages/JET/lopE4/src/toplevel/virtualprocess.jl:452
   [2719] #analyze_and_report_text!#131
        @ ~/.julia/packages/JET/lopE4/src/JET.jl:985 [inlined]
   [2720] analyze_and_report_file!(analyzer::JET.JETAnalyzer{JET.TypoPass}, filename::String, pkgid::Nothing; jetconfigs::@Kwargs{ignored_modules::Nothing, analyze_from_definitions::Bool, concretization_patterns::Vector{Symbol}, context::Module, target_defined_modules::Bool, toplevel_logger::Nothing, mode::Symbol})
        @ JET ~/.julia/packages/JET/lopE4/src/JET.jl:793
   [2721] analyze_and_report_file! (repeats 2 times)
        @ ~/.julia/packages/JET/lopE4/src/JET.jl:788 [inlined]
   [2722] report_file(args::String; jetconfigs::@Kwargs{ignored_modules::Nothing, analyze_from_definitions::Bool, concretization_patterns::Vector{Symbol}, context::Module, target_defined_modules::Bool, toplevel_logger::Nothing, mode::Symbol})
        @ JET ~/.julia/packages/JET/lopE4/src/analyzers/jetanalyzer.jl:1698
   [2723] report_file
        @ ~/.julia/packages/JET/lopE4/src/analyzers/jetanalyzer.jl:1695 [inlined]
   [2724] jet_test_file(file_path::String; ignored_modules::Nothing, jet_frames_to_skip::NTuple{4, Main.var"##JET error analysis - DataLoader#478".JETFrameFingerprint}, analyze_from_definitions::Bool, concretization_patterns::Vector{Symbol}, context::Module, target_defined_modules::Bool, mode::Symbol)
        @ Main.var"##JET error analysis - DataLoader#478" ~/packages/jet_test_utils.jl:266
   [2725] top-level scope
        @ ~/test/JET/RAICode/jet_data_loader_test.jl:20
   [2726] eval
        @ ./boot.jl:385 [inlined]
   [2727] #87
        @ ~/julia-depot-path/.julia/packages/ReTestItems/ELM7z/src/ReTestItems.jl:983 [inlined]
   [2728] with_source_path(f::ReTestItems.var"#87#91"{Expr}, path::String)
        @ ReTestItems ~/julia-depot-path/.julia/packages/ReTestItems/ELM7z/src/ReTestItems.jl:814
   [2729] #86
        @ ~/julia-depot-path/.julia/packages/ReTestItems/ELM7z/src/ReTestItems.jl:983 [inlined]
   [2730] redirect_stdio(f::ReTestItems.var"#86#90"{TestItem, Expr, Expr}; stdin::Nothing, stderr::IOContext{IOStream}, stdout::IOContext{IOStream})
        @ Base ./stream.jl:1413
   [2731] redirect_stdio
        @ ./stream.jl:1376 [inlined]
   [2732] _redirect_logs(f::ReTestItems.var"#86#90"{TestItem, Expr, Expr}, target::IOStream)
        @ ReTestItems ~/julia-depot-path/.julia/packages/ReTestItems/ELM7z/src/log_capture.jl:122
   [2733] #27
        @ ~/julia-depot-path/.julia/packages/ReTestItems/ELM7z/src/log_capture.jl:107 [inlined]
   [2734] open(::ReTestItems.var"#27#28"{ReTestItems.var"#86#90"{TestItem, Expr, Expr}}, ::String, ::Vararg{String}; kwargs::@Kwargs{})
        @ Base ./io.jl:396
   [2735] open
        @ ./io.jl:393 [inlined]
   [2736] _redirect_logs
        @ ~/julia-depot-path/.julia/packages/ReTestItems/ELM7z/src/log_capture.jl:107 [inlined]
   [2737] macro expansion
        @ ~/julia-depot-path/.julia/packages/ReTestItems/ELM7z/src/macros.jl:82 [inlined]
   [2738] runtestitem(ti::TestItem, ctx::ReTestItems.TestContext; test_end_expr::Expr, logs::Symbol, verbose_results::Bool, finish_test::Bool)
        @ ReTestItems ~/julia-depot-path/.julia/packages/ReTestItems/ELM7z/src/ReTestItems.jl:982
   [2739] top-level scope
        @ none:1
   [2740] eval
        @ ./boot.jl:385 [inlined]
   [2741] execute
        @ ~/julia-depot-path/.julia/packages/ReTestItems/ELM7z/src/workers.jl:303 [inlined]

Perhaps there is a cycle causing the stack overflow? Any idea how to mitigate this?

Actual tests running the analyzed code did not run into stack overflow.

Thanks!

@aviatesk
Copy link
Owner

Do you have a reproducer for this bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants