Skip to content

Commit 7f1add2

Browse files
authored
SharedArrays: Skip a finally step if we throw before the shmmem_create_pid local is defined (#61141)
In theory, if we throw on line 116 (e.g. if `getpid()` or `randstring()` throws), then we'll enter the `finally` block before we ever define `shmmem_create_pid`. I think this case is unlikely, but if we do hit it, we can't perform the `remotecall_fetch` call in the `finally` block, because `shmmem_create_pid` won't be defined. So this PR checks if `shmmem_create_pid` is defined before doing the `remotecall_fetch` call. Alternatively, we could lift lines 116 and 117 out of the `try` block, at which point it will no longer be possible (as far as I can tell) for us to throw before defining `shmmem_create_pid`. --- Detected by JET.
1 parent 03f7bcd commit 7f1add2

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

stdlib/SharedArrays/src/SharedArrays.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function SharedArray{T,N}(dims::Dims{N}; init=false, pids=Int[]) where {T,N}
153153
shm_seg_name = ""
154154

155155
finally
156-
if !isempty(shm_seg_name)
156+
if !isempty(shm_seg_name) && @isdefined shmmem_create_pid
157157
remotecall_fetch(shm_unlink, shmmem_create_pid, shm_seg_name)
158158
end
159159
end

0 commit comments

Comments
 (0)