# SharedArray example from documentation not working

**URL:** <https://discourse.julialang.org/t/sharedarray-example-from-documentation-not-working/18837>\
**Category:** Julia at Scale\
**Created:** [December 19, 2018, 6:49pm UTC](https://discourse.julialang.org/t/sharedarray-example-from-documentation-not-working/18837 "2018-12-19T18:49:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikkling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikkling/32/4978_2.png) [@mikkling](https://discourse.julialang.org/u/mikkling)\
**Post date:** [December 19, 2018, 6:49pm UTC](https://discourse.julialang.org/t/sharedarray-example-from-documentation-not-working/18837/1 "2018-12-19T18:49:15Z")

</div>

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|

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [December 19, 2018, 9:42pm UTC](https://discourse.julialang.org/t/sharedarray-example-from-documentation-not-working/18837/2 "2018-12-19T21:42:29Z")

</div>

It is an error in the docs: [Example in Julia document "Shared Arrays" report error when running · Issue #29611 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/29611)
