diff --git a/base/sharedarray.jl b/base/sharedarray.jl index fa9d42412c966..65d95ed7f2e8c 100644 --- a/base/sharedarray.jl +++ b/base/sharedarray.jl @@ -89,7 +89,7 @@ function SharedArray(T::Type, dims::NTuple; init=false, pids=Int[]) end # All good, immediately unlink the segment. - if prod(dims) > 0 + if (prod(dims) > 0) && (sizeof(T) > 0) if onlocalhost rc = shm_unlink(shm_seg_name) else @@ -508,7 +508,7 @@ function shm_mmap_array(T, dims, shm_seg_name, mode) local s = nothing local A = nothing - if prod(dims) == 0 + if (prod(dims) == 0) || (sizeof(T) == 0) return Array{T}(dims) end diff --git a/test/parallel_exec.jl b/test/parallel_exec.jl index 2e5ba5f35c7df..ecb89640b32ed 100644 --- a/test/parallel_exec.jl +++ b/test/parallel_exec.jl @@ -452,6 +452,13 @@ map!(x->1, d) @test 2.0 == remotecall_fetch(D->D[2], id_other, Base.shmem_fill(2.0, 2; pids=[id_me, id_other])) @test 3.0 == remotecall_fetch(D->D[1], id_other, Base.shmem_fill(3.0, 1; pids=[id_me, id_other])) +# Shared arrays of singleton immutables +@everywhere immutable ShmemFoo end +for T in [Void, ShmemFoo] + s = SharedArray(T, 10) + @test T() === remotecall_fetch(x->x[3], workers()[1], s) +end + # Issue #14664 d = SharedArray(Int,10) @sync @parallel for i=1:10