Skip to content

Commit

Permalink
fix close error due to race in d_closeall
Browse files Browse the repository at this point in the history
It seems possible that `DistributedArrays.d_closeall()` may encounter a condition where it finds a darray id in the `registry`, but the corresponding weakref value is `nothing` because the referenced darray got garbage collected. It has been enountered many times in CI and elsewhere, but is hard to replicate normally. Adding a check for the weakref value, before actially invoking `close` on it, to fix it.
  • Loading branch information
tanmaykm committed Oct 3, 2023
1 parent 9f5f09c commit 6f1f8ea
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ function d_closeall()
crefs = copy(refs)
for id in crefs
if id[1] == myid() # sanity check
haskey(registry, id) && close(d_from_weakref_or_d(id))
if haskey(registry, id)
d = d_from_weakref_or_d(id)
(d === nothing) || close(d)
end
yield()
end
end
Expand Down

0 comments on commit 6f1f8ea

Please sign in to comment.