Skip to content

Commit 06b4127

Browse files
committed
fix close error due to race in d_closeall
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 actually invoking `close` on it, to fix it.
1 parent 9f5f09c commit 06b4127

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/core.jl

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ function d_closeall()
4444
crefs = copy(refs)
4545
for id in crefs
4646
if id[1] == myid() # sanity check
47-
haskey(registry, id) && close(d_from_weakref_or_d(id))
47+
if haskey(registry, id)
48+
d = d_from_weakref_or_d(id)
49+
(d === nothing) || close(d)
50+
end
4851
yield()
4952
end
5053
end

0 commit comments

Comments
 (0)