Skip to content

Error in report_invalidations when invalidated method tree has no children #406

@ararslan

Description

@ararslan

The GitHub Actions job for checking invalidations failed on JuliaWeb/URIs.jl#63 with the following output:

(inv_total, inv_deps) = (1, 1)
[ Info: 1 methods invalidated for 1 functions
ERROR: LoadError: InexactError: Int64(NaN)
Stacktrace:
 [1] Int64
   @ ./float.jl:994 [inlined]
 [2] #3
   @ ~/.julia/packages/SnoopCompile/umz90/ext/SCPrettyTablesExt.jl:33 [inlined]
 [3] iterate
   @ ./generator.jl:48 [inlined]
 [4] _collect(c::Vector{Int64}, itr::Base.Generator{Vector{Int64}, SCPrettyTablesExt.var"#3#9"{Int64}}, ::Base.EltypeUnknown, isz::Base.HasShape{1})
   @ Base ./array.jl:811
 [5] collect_similar
   @ ./array.jl:720 [inlined]
 [6] map
   @ ./abstractarray.jl:3371 [inlined]
 [7] report_invalidations(io::IOContext{Base.PipeEndpoint}; invalidations::Vector{Any}, n_rows::Int64, process_filename::var"#1#2")
   @ SCPrettyTablesExt ~/.julia/packages/SnoopCompile/umz90/ext/SCPrettyTablesExt.jl:31
 [8] top-level scope
   @ ~/work/_temp/e7642433-c13a-41fb-861d-f3ad6083c2b6:13
in expression starting at /home/runner/work/_temp/e7642433-c13a-41fb-861d-f3ad6083c2b6:13

Full log here.

This appears to be happening because the invalidated method tree has no children.

(jl_zAHtQ6) pkg> status
Status `/private/var/folders/yw/ml6py_wx6vlffs_t678g81100000gp/T/jl_zAHtQ6/Project.toml`
  [08abe8d2] PrettyTables v2.4.0
  [aa65fe97] SnoopCompile v3.0.2
  [e2b509da] SnoopCompileCore v3.0.0
  [5c2747f8] URIs v1.5.1 `https://github.com/fredrikekre/URIs.jl#fe/tlv`

julia> using SnoopCompile, SnoopCompileCore, PrettyTables

julia> using SnoopCompile: countchildren

julia> invalidations = @snoop_invalidations using URIs
5-element Vector{Any}:
  MethodInstance for Artifacts.jointail(::Any, ::String)
 0
  Tuple{typeof(joinpath), Any, String}
  joinpath(uri::URI, parts::String...) @ URIs ~/.julia/packages/URIs/Fgl6j/src/URIs.jl:610
  "jl_method_table_insert"

julia> trees = reverse(invalidation_trees(invalidations))
1-element Vector{SnoopCompile.MethodInvalidations}:
 inserting joinpath(uri::URI, parts::String...) @ URIs ~/.julia/packages/URIs/Fgl6j/src/URIs.jl:610 invalidated:
   mt_backedges: 1: signature Tuple{typeof(joinpath), Any, String} triggered MethodInstance for Artifacts.jointail(::Any, ::String) (0 children)

julia> invs_per_method = map(countchildren, trees)
1-element Vector{Int64}:
 0

julia> sum_invs = sum(invs_per_method)
0

Since this is 0, populating the "Invalidations %" column in https://github.com/timholy/SnoopCompile.jl/blob/3de7217dc8ddd08b4048ba6614256a1f2e739bbb/ext/SCPrettyTablesExt.jl#L31-L34 errors, as 0/0 is NaN and Int(NaN) produces the InexactError as shown above.

An easy fix is to just not call Int and let the percent column be float-valued, but that seems like it could just be papering over an actual issue somewhere.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions