JuliaDebug / Cthulhu.jl

The slow descent into madness
MIT License
650 stars 41 forks source link

internal bug with print_callsite_info #505

Open vtjnash opened 1 year ago

vtjnash commented 1 year ago
julia> f(x) = 1
f (generic function with 1 method)

julia> f(::Vararg{T,T}) where {T} = "2"
f (generic function with 2 methods)

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

julia> descend(g, (Any,))
g(x) @ Main REPL[5]:1
1 g(x::Any)::Core.Const(1) = f(x::Any)
Select a call to descend into or ↩ to ascend. [q]uit. [b]ookmark.
Toggles: [w]arn, [h]ide type-stable statements, [t]ype annotations, [s]yntax highlight for Source/LLVM/Native, [j]ump to source always.
Show: [S]ource code, [A]ST, [T]yped code, [L]LVM IR, [N]ative code
Actions: [E]dit source code, [R]evise and redisplay
 • f(x::Any)
   ↩

g(x) @ Main REPL[5]:1
Variables
  #self#::Core.Const(g)
  x::ANY

∘ ─ %0 = invoke g(::Any)::Core.Const(1)
    @ REPL[5]:1 within `g`
1 ─ %1 = Main.f(x)::Core.Const(1)
└──      return %1
Select a call to descend into or ↩ to ascend. [q]uit. [b]ookmark.
Toggles: [w]arn, [h]ide type-stable statements, [t]ype annotations, [s]yntax highlight for Source/LLVM/Native, [j]ump to source always, [o]ptimize, [d]ebuginfo, [r]emarks, [e]ffects, [i]nlining costs.
Show: [S]ource code, [A]ST, [T]yped code, [L]LVM IR, [N]ative code
Actions: [E]dit source code, [R]evise and redisplay
Advanced: dump [P]arams cache.
 • %1 = call → f(::Any)::Core.Const(1)
   ↩
ERROR: MethodError: no method matching widenconst(::Int64)

Closest candidates are:
  widenconst(!Matched::Core.TypeofVararg)
   @ Core compiler/typelattice.jl:699
  widenconst(!Matched::Core.Compiler.LimitedAccuracy)
   @ Core compiler/typelattice.jl:700
  widenconst(!Matched::Core.Compiler.PartialTypeVar)
   @ Core compiler/typelattice.jl:694
  ...

Stacktrace:
  [1] headstring(T::Any)
    @ Cthulhu ~/.julia/dev/Cthulhu/src/callsite.jl:182
  [2] __show_limited(limiter::WidthLimitedIO.TextWidthLimiter, name::Symbol, tt::Core.SimpleVector, rt::Any, effects::Core.Compiler.Effects)
    @ Cthulhu ~/.julia/dev/Cthulhu/src/callsite.jl:210
  [3] show_callinfo(limiter::WidthLimitedIO.TextWidthLimiter, mici::Cthulhu.MICallInfo)
    @ Cthulhu ~/.julia/dev/Cthulhu/src/callsite.jl:257
  [4] print_callsite_info(limiter::WidthLimitedIO.TextWidthLimiter, info::Cthulhu.UncachedCallInfo)
    @ Cthulhu ~/.julia/dev/Cthulhu/src/callsite.jl:320
  [5] show(io::IOContext{IOBuffer}, c::Cthulhu.Callsite)
    @ Cthulhu ~/.julia/dev/Cthulhu/src/callsite.jl:411
  [6] (::Cthulhu.var"#32#33"{Cthulhu.Callsite, Bool, Bool, Bool, Tuple{Int64, Int64}})(io::IOBuffer)
    @ Cthulhu ~/.julia/dev/Cthulhu/src/ui.jl:19
  [7] sprint(::Function; context::Nothing, sizehint::Int64)
    @ Base ./strings/io.jl:114
  [8] sprint
    @ Base ./strings/io.jl:107 [inlined]
  [9] show_as_line(callsite::Cthulhu.Callsite, with_effects::Bool, optimize::Bool, iswarn::Bool)
    @ Cthulhu ~/.julia/dev/Cthulhu/src/ui.jl:18
 [10] #35
    @ Base ~/.julia/dev/Cthulhu/src/ui.jl:51 [inlined]
 [11] iterate
    @ Base ./generator.jl:47 [inlined]
 [12] _collect(c::Vector{Cthulhu.Callsite}, itr::Base.Generator{Vector{Cthulhu.Callsite}, Cthulhu.var"#35#36"{Bool, Bool, Bool}}, ::Base.EltypeUnknown, isz::Base.HasShape{1})
    @ Base ./array.jl:852
 [13] collect_similar(cont::Vector{Cthulhu.Callsite}, itr::Base.Generator{Vector{Cthulhu.Callsite}, Cthulhu.var"#35#36"{Bool, Bool, Bool}})
    @ Base ./array.jl:761
 [14] map(f::Function, A::Vector{Cthulhu.Callsite})
    @ Base ./abstractarray.jl:3275
 [15] build_options(callsites::Vector{Cthulhu.Callsite}, with_effects::Bool, optimize::Bool, iswarn::Bool, ::Bool)
    @ Cthulhu ~/.julia/dev/Cthulhu/src/ui.jl:50
 [16] Cthulhu.CthulhuMenu(callsites::Vector{…}, with_effects::Bool, optimize::Bool, iswarn::Bool, hide_type_stable::Bool, custom_toggles::Vector{…}; pagesize::Int64, sub_menu::Bool, kwargs::@Kwargs{…})
    @ Cthulhu ~/.julia/dev/Cthulhu/src/ui.jl:32
 [17] 
    @ Cthulhu ~/.julia/dev/Cthulhu/src/Cthulhu.jl:569
 [18] _descend
    @ Cthulhu ~/.julia/dev/Cthulhu/src/Cthulhu.jl:382 [inlined]
 [19] _descend
    @ Cthulhu ~/.julia/dev/Cthulhu/src/Cthulhu.jl:756 [inlined]
 [20] #_descend#109
    @ Cthulhu ~/.julia/dev/Cthulhu/src/Cthulhu.jl:772 [inlined]
 [21] __descend_with_error_handling(args::Any; terminal::Any, kwargs...)
    @ Cthulhu ~/.julia/dev/Cthulhu/src/Cthulhu.jl:213
 [22] _descend_with_error_handling(f::Any, argtypes::Any; kwargs::@Kwargs{iswarn::Bool})
    @ Cthulhu ~/.julia/dev/Cthulhu/src/Cthulhu.jl:202
 [23] descend_code_typed(::Any, ::Vararg{Any}; kwargs::@Kwargs{})
    @ Cthulhu ~/.julia/dev/Cthulhu/src/Cthulhu.jl:160
 [24] top-level scope
    @ REPL[6]:1
Some type information was truncated. Use `show(err)` to see complete types.
simeonschaub commented 1 week ago

It's now a different error which affects code_typed as well. Reported upstream: JuliaLang/julia#55916