forked from Mirror/wren
Fix deadlock bug in map insertion.
This commit is contained in:
@ -388,14 +388,9 @@ static bool addEntry(MapEntry* entries, uint32_t capacity,
|
||||
// If we found an open slot, the key is not in the table.
|
||||
if (IS_UNDEFINED(entry->key))
|
||||
{
|
||||
// Don't stop at a tombstone, though, because the key may be found after
|
||||
// it.
|
||||
if (IS_FALSE(entry->value))
|
||||
{
|
||||
entry->key = key;
|
||||
entry->value = value;
|
||||
return true;
|
||||
}
|
||||
entry->key = key;
|
||||
entry->value = value;
|
||||
return true;
|
||||
}
|
||||
else if (wrenValuesEqual(entry->key, key))
|
||||
{
|
||||
|
||||
11
test/core/map/churn.wren
Normal file
11
test/core/map/churn.wren
Normal file
@ -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