fix: correct tombstone handling in map insertion to prevent deadlock
The addEntry function was incorrectly skipping tombstone entries when inserting new keys, causing the map to fill up with tombstones and eventually deadlock on insert. The fix removes the tombstone check that prevented overwriting tombstone slots with new entries, allowing proper reuse of removed entries. A regression test (test/core/map/churn.wren) was added to verify that inserting and removing entries in a loop correctly maintains the map count without deadlocking.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
// This is a regression test for a bug where inserting in a map would not
|
||||
// correctly reuse tombstone entries, eventually deadlocking on insert.
|
||||
var map = {}
|
||||
|
||||
for (i in 0...100) {
|
||||
map[i] = i
|
||||
|
||||
if (i >= 10) map.remove(i - 10)
|
||||
}
|
||||
|
||||
IO.print(map.count) // expect: 10
|
||||
Reference in New Issue
Block a user