DistributedArrays is not thread-safe
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- julia
调研方向
从 src/darray.jl 开始,尤其检查 stack trace 中显示的 DArray 构造函数和 construct_localparts 路径,并检查 DistributedArrays.registry 的使用情况。首先运行 issue 中的 concurrent distribute 复现程序。当并发调用不再触发 Dict concurrent-write 断言,并且相关行为已由测试覆盖时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Due to the use of globals such as DistributedArrays.registry, currently DistributedArrays is not thread-safe:
julia> versioninfo()
Julia Version 1.11.6
Commit 9615af0f269 (2025-07-09 12:58 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (arm64-apple-darwin24.0.0)
CPU: 10 × Apple M2 Pro
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, apple-m2)
Threads: 6 default, 0 interactive, 3 GC (on 6 virtual cores)
Environment:
JULIA_PKG_USE_CLI_GIT = true
JULIA_PKG_PRESERVE_TIERED_INSTALLED = true
julia> using DistributedArrays
julia> v = [rand(10) for _ in 1:1000];
julia> @sync for vi in v
Threads.@spawn distribute(vi)
end;
ERROR: TaskFailedException
nested task error: TaskFailedException
nested task error: AssertionError: Multiple concurrent writes to Dict detected!
Stacktrace:
[1] _setindex!
@ ./dict.jl:337 [inlined]
[2] setindex!(h::Dict{Any, Nothing}, v0::Nothing, key::Tuple{Int64, Int64})
@ Base ./dict.jl:363
[3] push!
@ ./set.jl:137 [inlined]
[4] DArray{…}(id::Tuple{…}, dims::Tuple{…}, pids::Vector{…}, indices::Vector{…}, cuts::Vector{…}, lp::Vector{…})
@ DistributedArrays ~/.julia/packages/DistributedArrays/SxLCk/src/darray.jl:47
[5] construct_localparts(init::DistributedArrays.var"#73#75"{…}, id::Tuple{…}, dims::Tuple{…}, pids::Vector{…}, idxs::Vector{…}, cuts::Vector{…}; T::Nothing, A::Nothing)
@ DistributedArrays ~/.julia/packages/DistributedArrays/SxLCk/src/darray.jl:126
[6] construct_localparts(init::Function, id::Tuple{…}, dims::Tuple{…}, pids::Vector{…}, idxs::Vector{…}, cuts::Vector{…})
@ DistributedArrays ~/.julia/packages/DistributedArrays/SxLCk/src/darray.jl:117
[7] #invokelatest#2
@ ./essentials.jl:1055 [inlined]
[8] invokelatest
@ ./essentials.jl:1052 [inlined]
[9] #153
@ ~/.julia/juliaup/julia-1.11.6+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/Distributed/src/remotecall.jl:425 [inlined]
[10] run_work_thunk(thunk::Distributed.var"#153#154"{…}, print_error::Bool)
@ Distributed ~/.julia/juliaup/julia-1.11.6+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/Distributed/src/process_messages.jl:70
[11] #remotecall_fetch#158
@ ~/.julia/juliaup/julia-1.11.6+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/Distributed/src/remotecall.jl:450 [inlined]
[12] remotecall_fetch
@ ~/.julia/juliaup/julia-1.11.6+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/Distributed/src/remotecall.jl:449 [inlined]
[13] remotecall_fetch
@ ~/.julia/juliaup/julia-1.11.6+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/Distributed/src/remotecall.jl:492 [inlined]
[14] (::DistributedArrays.var"#1#3"{…})()
@ DistributedArrays ~/.julia/packages/DistributedArrays/SxLCk/src/darray.jl:88
Stacktrace:
[1] #remotecall_fetch#158
@ ~/.julia/juliaup/julia-1.11.6+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/Distributed/src/remotecall.jl:451 [inlined]
[2] remotecall_fetch
@ ~/.julia/juliaup/julia-1.11.6+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/Distributed/src/remotecall.jl:449 [inlined]
[3] remotecall_fetch
@ ~/.julia/juliaup/julia-1.11.6+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/Distributed/src/remotecall.jl:492 [inlined]
[4] (::DistributedArrays.var"#1#3"{…})()
@ DistributedArrays ~/.julia/packages/DistributedArrays/SxLCk/src/darray.jl:88
Stacktrace:
[1] sync_end(c::Channel{Any})
@ Base ./task.jl:466
[2] macro expansion
@ ./task.jl:499 [inlined]
[3] DArray(id::Tuple{…}, init::Function, dims::Tuple{…}, pids::Vector{…}, idxs::Vector{…}, cuts::Vector{…})
@ DistributedArrays ~/.julia/packages/DistributedArrays/SxLCk/src/darray.jl:83
[4] DArray(init::Function, dims::Tuple{Int64}, procs::Vector{Int64}, dist::Vector{Int64})
@ DistributedArrays ~/.julia/packages/DistributedArrays/SxLCk/src/darray.jl:177
[5] distribute(A::Vector{Float64}; procs::Vector{Int64}, dist::Vector{Int64})
@ DistributedArrays ~/.julia/packages/DistributedArrays/SxLCk/src/darray.jl:550
[6] distribute(A::Vector{Float64})
@ DistributedArrays ~/.julia/packages/DistributedArrays/SxLCk/src/darray.jl:540
[7] (::var"#7#8"{Vector{Float64}})()
@ Main ./REPL[6]:2
...and 3 more exceptions.
Stacktrace:
[1] sync_end(c::Channel{Any})
@ Base ./task.jl:466
[2] macro expansion
@ task.jl:499 [inlined]
[3] top-level scope
@ REPL[6]:1
Some type information was truncated. Use `show(err)` to see complete types.
AFAICT this could be fixed by using task-local states (OncePerTask on Julia >= 1.12).
- 主要语言
- Julia
- 星标
- 205
- 派生
- 34
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
JuliaParallel/DistributedArrays.jl 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 45/100
JuliaParallel/DistributedArrays.jl#239 · 1 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 45/100
JuliaParallel/DistributedArrays.jl#238 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
-
难度 4/5 3-5 天 新手友好度 30/100
-
难度 4/5 3-5 天 新手友好度 35/100
查看 JuliaParallel/DistributedArrays.jl 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
JuliaParallel/Hwloc.jl#93 ·
-
Affine transformations of `JohnsonSU` could return a `JohnsonSU`可能已有人在做 @devmotion 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
JuliaStats/Distributions.jl#2117 ·
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 80/100
TomerAberbach/profiler-md#970 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
grame-cncm/faust#1409 ·
维护者通常 1 天内回复