Skip to content

Commit 6be86a3

Browse files
authored
Fix a concurrency bug in iterate(::Dict) (#44534)
1 parent 5ec1f9f commit 6be86a3

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

NEWS.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ Build system changes
3030
New library functions
3131
---------------------
3232

33+
Library changes
34+
---------------
3335

34-
New library features
35-
--------------------
36+
* A known concurrency issue of `iterate` methods on `Dict` and other derived objects such
37+
as `keys(::Dict)`, `values(::Dict)`, and `Set` is fixed. These methods of `iterate` can
38+
now be called on a dictionary or set shared by arbitrary tasks provided that there are no
39+
tasks mutating the dictionary or set ([#44534]).
3640

3741

3842
Standard library changes

base/dict.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ end
703703

704704
@propagate_inbounds _iterate(t::Dict{K,V}, i) where {K,V} = i == 0 ? nothing : (Pair{K,V}(t.keys[i],t.vals[i]), i == typemax(Int) ? 0 : i+1)
705705
@propagate_inbounds function iterate(t::Dict)
706-
_iterate(t, skip_deleted_floor!(t))
706+
_iterate(t, skip_deleted(t, t.idxfloor))
707707
end
708708
@propagate_inbounds iterate(t::Dict, i) = _iterate(t, skip_deleted(t, i))
709709

0 commit comments

Comments
 (0)