JunoLab / Traceur.jl

Other
319 stars 15 forks source link

Traceur + Cubature compile failure #50

Closed gustaphe closed 2 years ago

gustaphe commented 3 years ago

Running @trace on Cubature.jl's hcubature errors out, with error compiling ... in context Cassette.Context... (full output below). This also happens when called in a module, even if I explicitly trace only the module:

module MyModule
using Cubature
export findout
findout() = hcubature(x -> x[1]^2, [-1, -1], [2, 1])
end
julia> using MyModule, Traceur
julia> @trace findout() modules=[MyModule]
ERROR ...
Complete output ```julia julia> @trace hcubature(x -> x[1]^2, [-1, -1], [2, 1]) ┌ Warning: is assigned as Tuple{Int64, Int64} └ @ array.jl:108 ┌ Warning: is assigned as Union{Nothing, Tuple{Int64, Int64}} └ @ array.jl:108 ERROR: ERROR COMPILING (typeof(Cubature.integrands), Cubature.IntegrandData{var"#20#22"}, Bool, Bool, Bool) IN CONTEXT Cassette.Context{Traceur.var"##TraceurCtx#Name", Traceur.Trace, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}: UndefVarError: spvals not defined 43-element Vector{Base.StackTraces.StackFrame}: _partially_inline!(x::Any, slot_replacements::Vector{Any}, type_signature::Any, static_param_values::Vector{Any}, slot_offset::Int64, statement_offset::Int64, boundscheck::Symbol) at meta.jl:365 partially_inline!(code::Vector{Any}, slot_replacements::Vector{Any}, type_signature::Any, static_param_values::Vector{Any}, slot_offset::Int64, statement_offset::Int64, boundscheck::Symbol) at meta.jl:312 overdub_pass!(reflection::Cassette.Reflection, context_type::DataType, is_invoke::Bool) at overdub.jl:262 __overdub_generator__(self::Type, context_type::Type, args::NTuple{5, DataType}) at overdub.jl:594 (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any, N} where N) at boot.jl:571 get_staged(li::Core.MethodInstance) at utilities.jl:111 retrieve_code_info at utilities.jl:122 [inlined] Core.Compiler.InferenceState(result::Core.Compiler.InferenceResult, cached::Bool, interp::Core.Compiler.NativeInterpreter) at inferencestate.jl:131 typeinf_ext(interp::Core.Compiler.NativeInterpreter, mi::Core.MethodInstance) at typeinfer.jl:890 typeinf_ext_toplevel(interp::Core.Compiler.NativeInterpreter, linfo::Core.MethodInstance) at typeinfer.jl:925 typeinf_ext_toplevel(mi::Core.MethodInstance, world::UInt64) at typeinfer.jl:921 overdub(::Cassette.Context{Traceur.var"##TraceurCtx#Name", Traceur.Trace, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}, ::Function, ::Cubature.IntegrandData{var"#20#22"}, ::Bool, ::Bool, ::Bool) at trace.jl:47 overdub at Cubature.jl:165 [inlined] overdub(::Cassette.Context{Traceur.var"##TraceurCtx#Name", Traceur.Trace, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}, ::typeof(Cubature.cubature), ::Bool, ::Bool, ::Bool, ::Bool, ::Int64, ::var"#20#22", ::Vector{Int64}, ::Vector{Int64}, ::Float64, ::Int64, ::Int64, ::Int32) at overdub.jl:0 overdub(::Cassette.Context{Traceur.var"##TraceurCtx#Name", Traceur.Trace, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}, ::Function, ::Bool, ::Bool, ::Bool, ::Bool, ::Vararg{Any, N} where N) at trace.jl:47 var" at Cubature.jl:230 [inlined] overdub at Cubature.jl:230 [inlined] overdub(::Cassette.Context{Traceur.var"##TraceurCtx#Name", Traceur.Trace, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}, ::Cubature.var"##hcubature#22", ::Float64, ::Int64, ::Int64, ::typeof(hcubature), ::var"#20#22", ::Vector{Int64}, ::Vector{Int64}) at overdub.jl:0 overdub at trace.jl:47 [inlined] hcubature(::var" at Cubature.jl:230 [inlined] overdub at Cubature.jl:230 [inlined] overdub(::Cassette.Context{Traceur.var"##TraceurCtx#Name", Traceur.Trace, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}, ::typeof(hcubature), ::var"#20#22", ::Vector{Int64}, ::Vector{Int64}) at overdub.jl:0 overdub(::Cassette.Context{Traceur.var"##TraceurCtx#Name", Traceur.Trace, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}, ::Function, ::Function, ::Vector{Int64}, ::Vector{Int64}) at trace.jl:47 (::var" at trace.jl:88 [inlined] recurse at trace.jl:88 [inlined] recurse(overdub_context#257::Cassette.Context{Traceur.var"##TraceurCtx#Name", Traceur.Trace, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}, overdub_arguments#258::var"#19#21") at overdub.jl:0 trace(w::Function, f::Function; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) at trace.jl:51 trace at trace.jl:51 [inlined] #warntrace#21 at trace.jl:54 [inlined] warntrace(f::Function) at trace.jl:54 top-level scope at trace.jl:88 eval at boot.jl:360 [inlined] eval_user_input(ast::Any, backend::REPL.REPLBackend) at REPL.jl:139 repl_backend_loop(backend::REPL.REPLBackend) at REPL.jl:200 start_repl_backend(backend::REPL.REPLBackend, consumer::Any) at REPL.jl:185 run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool) at REPL.jl:317 run_repl(repl::REPL.AbstractREPL, consumer::Any) at REPL.jl:305 (::Base.var"#874#876"{Bool, Bool, Bool})(REPL::Module) at client.jl:387 #invokelatest#2 at essentials.jl:708 [inlined] invokelatest at essentials.jl:706 [inlined] run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool) at client.jl:372 exec_options(opts::Base.JLOptions) at client.jl:302 _start() at client.jl:485 Stacktrace: [1] error(s::String) @ Base ./error.jl:33 [2] macro expansion @ ~/.julia/packages/Cassette/jxIEh/src/overdub.jl:602 [inlined] [3] overdub(::Cassette.Context{nametype(TraceurCtx), Traceur.Trace, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}, ::typeof(Cubature.integrands), ::Cubature.IntegrandData{var"#20#22"}, ::Bool, ::Bool, ::Bool) @ Cassette ~/.julia/packages/Cassette/jxIEh/src/overdub.jl:654 [4] overdub(::Cassette.Context{nametype(TraceurCtx), Traceur.Trace, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}, ::Function, ::Cubature.IntegrandData{var"#20#22"}, ::Bool, ::Bool, ::Bool) @ Traceur ~/.julia/packages/Traceur/ajxdS/src/trace.jl:47 [5] overdub @ ~/.julia/packages/Cubature/5zwuu/src/Cubature.jl:165 [inlined] [6] overdub(::Cassette.Context{nametype(TraceurCtx), Traceur.Trace, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}, ::typeof(Cubature.cubature), ::Bool, ::Bool, ::Bool, ::Bool, ::Int64, ::var"#20#22", ::Vector{Int64}, ::Vector{Int64}, ::Float64, ::Int64, ::Int64, ::Int32) @ Cassette ~/.julia/packages/Cassette/jxIEh/src/overdub.jl:0 [7] overdub(::Cassette.Context{nametype(TraceurCtx), Traceur.Trace, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}, ::Function, ::Bool, ::Bool, ::Bool, ::Bool, ::Vararg{Any, N} where N) @ Traceur ~/.julia/packages/Traceur/ajxdS/src/trace.jl:47 [8] var" @ ~/.julia/packages/Cubature/5zwuu/src/Cubature.jl:230 [inlined] [9] overdub @ ~/.julia/packages/Cubature/5zwuu/src/Cubature.jl:230 [inlined] [10] overdub(::Cassette.Context{nametype(TraceurCtx), Traceur.Trace, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}, ::Cubature.var"##hcubature#22", ::Float64, ::Int64, ::Int64, ::typeof(hcubature), ::var"#20#22", ::Vector{Int64}, ::Vector{Int64}) @ Cassette ~/.julia/packages/Cassette/jxIEh/src/overdub.jl:0 [11] overdub @ ~/.julia/packages/Traceur/ajxdS/src/trace.jl:47 [inlined] [12] hcubature(::var" @ ~/.julia/packages/Cubature/5zwuu/src/Cubature.jl:230 [inlined] [13] overdub @ ~/.julia/packages/Cubature/5zwuu/src/Cubature.jl:230 [inlined] [14] overdub(::Cassette.Context{nametype(TraceurCtx), Traceur.Trace, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}, ::typeof(hcubature), ::var"#20#22", ::Vector{Int64}, ::Vector{Int64}) @ Cassette ~/.julia/packages/Cassette/jxIEh/src/overdub.jl:0 [15] overdub(::Cassette.Context{nametype(TraceurCtx), Traceur.Trace, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}, ::Function, ::Function, ::Vector{Int64}, ::Vector{Int64}) @ Traceur ~/.julia/packages/Traceur/ajxdS/src/trace.jl:47 [16] (::var" @ ~/.julia/packages/Traceur/ajxdS/src/trace.jl:88 [inlined] [17] recurse @ ~/.julia/packages/Traceur/ajxdS/src/trace.jl:88 [inlined] [18] recurse(overdub_context#257::Cassette.Context{nametype(TraceurCtx), Traceur.Trace, Nothing, Cassette.var"##PassType#259", Nothing, Nothing}, overdub_arguments#258::var"#19#21") @ Cassette ~/.julia/packages/Cassette/jxIEh/src/overdub.jl:0 [19] trace(w::Function, f::Function; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) @ Traceur ~/.julia/packages/Traceur/ajxdS/src/trace.jl:51 [20] trace @ ~/.julia/packages/Traceur/ajxdS/src/trace.jl:51 [inlined] [21] #warntrace#21 @ ~/.julia/packages/Traceur/ajxdS/src/trace.jl:54 [inlined] [22] warntrace(f::Function) @ Traceur ~/.julia/packages/Traceur/ajxdS/src/trace.jl:54 [23] top-level scope @ ~/.julia/packages/Traceur/ajxdS/src/trace.jl:88 ```

System:

Julia v1.6
Traceur v0.3.1
Cubature v1.5.1
Cassette v0.3.5
pfitzseb commented 3 years ago

That very much looks like a Cassette bug.