From 6f1f8eaa053efce66e1a5bcc59584089c228cb83 Mon Sep 17 00:00:00 2001 From: tan Date: Tue, 3 Oct 2023 12:20:40 +0530 Subject: [PATCH] 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 actially invoking `close` on it, to fix it. --- src/core.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core.jl b/src/core.jl index abb8415..5192f22 100644 --- a/src/core.jl +++ b/src/core.jl @@ -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