Skip to content

Commit

Permalink
Detect multiple concurent writes to Dict + remove dead code (JuliaLan…
Browse files Browse the repository at this point in the history
…g#44778)

Thanks to JuliaLang#38180, the removed code seems to be dead because no finalizers should be used anymore to modify dictionaries (it was dangerous). Furthermore, it may help users to detect illegal concurrent writes, since it doesn't recurse and have new error message. There should be no, or even a positive, performance effect.
  • Loading branch information
petvana committed Apr 4, 2022
1 parent 209aad1 commit 51271e0
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions base/dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,22 +223,17 @@ end
keys[index] = k
vals[index] = v
count += 1

if h.age != age0
# if `h` is changed by a finalizer, retry
return rehash!(h, newsz)
end
end
end

@assert h.age == age0 "Muliple concurent writes to Dict detected!"
h.age += 1
h.slots = slots
h.keys = keys
h.vals = vals
h.count = count
h.ndel = 0
h.maxprobe = maxprobe
@assert h.age == age0

return h
end

Expand Down

0 comments on commit 51271e0

Please sign in to comment.