-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
I have a case where I get stuck in an infinite loop here
SnoopCompile.jl/SnoopCompileCore/src/snoop_inference.jl
Lines 127 to 155 in a0a03f3
| function addchildren!(parent::InferenceTimingNode, cis, backedges, miidx, backtraces) | |
| handled = Set{CodeInstance}() | |
| for (i, ci) in pairs(cis) | |
| ci ∈ handled && continue | |
| # Follow the backedges to the root | |
| j = i | |
| be = ci | |
| while true | |
| found = false | |
| for k in backedges[j] | |
| k < j && continue # don't get caught in cycles | |
| be = cis[k] | |
| if be ∉ handled | |
| j = k | |
| found = true | |
| break | |
| end | |
| end | |
| found || break # quit when no unhandled backedge found | |
| end | |
| be ∈ handled && continue | |
| # bt1, bt2 = get(backtraces, Core.Compiler.get_ci_mi(be), (nothing, nothing)) | |
| # child = InferenceTimingNode(be, make_stacktrace(bt1, bt2), parent) | |
| child = InferenceTimingNode(be, get(backtraces, be, nothing), parent) | |
| push!(handled, be) | |
| addchildren!(child, handled, miidx) | |
| end | |
| return parent | |
| end |
I think what's happening is that be ∉ handled is true the first time it is tested, for k == j. That means that j never increments, and the loop never ends. I don't understand what's being done here, but if I change line 137 to
k ≤ j && continue # don't get caught in cyclesinstead of k < j, then there's no infinite loop, and the output looks reasonable. Is this a correct fix?
Metadata
Metadata
Assignees
Labels
No labels