SharedArray example from documentation not working


#1

I’m trying to learn the intricacies of distributed computing, and was having troubles with SharedArrays not being available on workers. I went back to the documentation and tried the example. It threw the error below!

I’m using Julia-1.0.3 on Ubuntu 18.10.

julia> using Distributed

julia>

julia> addprocs(3)
3-element Array{Int64,1}:
2
3
4

julia> @everywhere using SharedArrays

julia> S = SharedArray{Int,2}((3, 4), init = S -> S[localindices(S)] = myid())

ERROR: On worker 2:
MethodError: no method matching setindex_shape_check(::Int64, ::Int64)
Closest candidates are:
setindex_shape_check(::AbstractArray{#s57,1} where #s57, ::Integer) at indices.jl:218
setindex_shape_check(::AbstractArray{#s57,1} where #s57, ::Integer, ::Integer) at indices.jl:221
setindex_shape_check(::AbstractArray{#s57,2} where #s57, ::Integer, ::Integer) at indices.jl:225

macro expansion at ./multidimensional.jl:649 [inlined]
_unsafe_setindex! at ./multidimensional.jl:644
_setindex! at ./multidimensional.jl:639 [inlined]
setindex! at ./abstractarray.jl:998 [inlined]
#3 at ./REPL[5]:1
#116 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Distributed/src/process_messages.jl:276
run_work_thunk at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Distributed/src/process_messages.jl:56
run_work_thunk at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Distributed/src/process_messages.jl:65
#102 at ./task.jl:259
#remotecall_wait#154(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Function, ::Distributed.Worker, ::SharedArray{Int64,2}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Distributed/src/remotecall.jl:421
remotecall_wait(::Function, ::Distributed.Worker, ::SharedArray{Int64,2}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Distributed/src/remotecall.jl:412
#remotecall_wait#157(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Function, ::Int64, ::SharedArray{Int64,2}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Distributed/src/remotecall.jl:433
remotecall_wait(::Function, ::Int64, ::SharedArray{Int64,2}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Distributed/src/remotecall.jl:433
(::getfield(SharedArrays, Symbol("##30#31")){SharedArray{Int64,2},getfield(Main, Symbol("##3#4"))})() at ./task.jl:259

…and 2 more exception(s).

Stacktrace:
[1] sync_end(::Array{Any,1}) at ./task.jl:226
[2] macro expansion at ./task.jl:245 [inlined]
[3] initialize_shared_array(::SharedArray{Int64,2}, ::Bool, ::Function, ::Array{Int64,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/SharedArrays/src/SharedArrays.jl:253
[4] #call#3(::Function, ::Array{Int64,1}, ::Type{SharedArray{Int64,2}}, ::Tuple{Int64,Int64}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/SharedArrays/src/SharedArrays.jl:150
[5] (::getfield(Core, Symbol("#kw#Type")))(::NamedTuple{(:init,),Tuple{getfield(Main, Symbol("##3#4"))}}, ::Type{SharedArray{Int64,2}}, ::Tuple{Int64,Int64}) at ./none:0
[6] top-level scope at none:0

Is there something wrong with my installation?

|m|


#2

It is an error in the docs: https://github.com/JuliaLang/julia/issues/29611