From 51271e0f2a8b15f5e7abf417d058980561750fe1 Mon Sep 17 00:00:00 2001 From: Petr Vana Date: Mon, 4 Apr 2022 06:17:56 +0200 Subject: [PATCH] Detect multiple concurent writes to Dict + remove dead code (#44778) Thanks to #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. --- base/dict.jl | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/base/dict.jl b/base/dict.jl index 1ad84df0aa89e..59b59ad680c31 100644 --- a/base/dict.jl +++ b/base/dict.jl @@ -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