Skip to content

Truncated stacktraces on Windows for specific code #41750

@timholy

Description

@timholy

SnoopCompile can now inventory all runtime dispatches that result in type-inference, but @ChrisRackauckas and I have found a case where this works on Linux but not on Windows.. Here's a demo that works on both platforms:

julia> using SnoopCompile

julia> f(x::Real) = sizeof(x)
f (generic function with 1 method)

julia> g(x) = f(Base.inferencebarrier(x))
g (generic function with 1 method)

julia> tinf = @snoopi_deep g(1)
InferenceTimingNode: 0.006272/0.006679 on Core.Compiler.Timings.ROOT() with 2 direct children

julia> itrigs = inference_triggers(tinf)
2-element Vector{InferenceTrigger}:
 Inference triggered to call g(::Int64) from eval (.\boot.jl:373) inlined into REPL.eval_user_input(::Any, ::REPL.REPLBackend) (C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\REPL\src\REPL.jl:150)
 Inference triggered to call f(::Int64) from g (.\REPL[3]:1) with specialization g(::Int64)

julia> stacktrace(itrigs[2])
19-element Vector{Base.StackTraces.StackFrame}:
 exit_current_timer at typeinfer.jl:164 [inlined]
 typeinf(interp::Core.Compiler.NativeInterpreter, frame::Core.Compiler.InferenceState) at typeinfer.jl:206
 typeinf_ext(interp::Core.Compiler.NativeInterpreter, mi::Core.MethodInstance) at typeinfer.jl:908
 typeinf_ext_toplevel(interp::Core.Compiler.NativeInterpreter, linfo::Core.MethodInstance) at typeinfer.jl:941
 typeinf_ext_toplevel(mi::Core.MethodInstance, world::UInt64) at typeinfer.jl:937
 g(x::Int64) at REPL[3]:1
 top-level scope at snoopi_deep.jl:53
 eval at boot.jl:373 [inlined]
 eval_user_input(ast::Any, backend::REPL.REPLBackend) at REPL.jl:150
 repl_backend_loop(backend::REPL.REPLBackend) at REPL.jl:241
 start_repl_backend(backend::REPL.REPLBackend, consumer::Any) at REPL.jl:226
 run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool) at REPL.jl:359
 run_repl(repl::REPL.AbstractREPL, consumer::Any) at REPL.jl:346
 (::Base.var"#919#921"{Bool, Bool, Bool})(REPL::Module) at client.jl:394
 #invokelatest#2 at essentials.jl:716 [inlined]
 invokelatest at essentials.jl:714 [inlined]
 run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool) at client.jl:379
 exec_options(opts::Base.JLOptions) at client.jl:309
 _start() at client.jl:495

The key line is the g(x::Int64) at REPL[3]:1 (6th one down), which is the caller of f. You can see the full stacktrace including C-frames with stacktrace(itrigs[2].node.bt, true).

So, this much works for both of us. However, this one does not (on 1.7.0-beta3):

(@v1.7) pkg> add DiffEqBase#cthulhu OrdinaryDiffEq#cthulhu SnoopCompile

using OrdinaryDiffEq, SnoopCompile
function lorenz(du,u,p,t)
 du[1] = 10.0(u[2]-u[1])
 du[2] = u[1]*(28.0-u[3]) - u[2]
 du[3] = u[1]*u[2] - (8/3)*u[3]
end
u0 = [1.0;0.0;0.0]
tspan = (0.0,100.0)
prob = ODEProblem(OrdinaryDiffEq.lorenz,u0,tspan)
alg = Tsit5()
tinf = @snoopi_deep solve(prob,alg)
itrigs = inference_triggers(tinf)

Now for all the itrigs the stacktrace terminates after compiler/typeinfer.jl (just the first 5 entries).

Full details: JuliaDebug/Cthulhu.jl#185

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviorsystem:windowsAffects only Windows

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions