From a8e5f6ced073de06ce4db866dc6a00a0e775a7d5 Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Mon, 6 Aug 2018 14:51:04 +0100 Subject: [PATCH] Fix another bug in the hash table. Clearing the secondMaps was incorrect for cases where the secondMaps included a wrap around to the start of the table. --- hash_table.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hash_table.h b/hash_table.h index 559dd39..072fcf6 100644 --- a/hash_table.h +++ b/hash_table.h @@ -394,9 +394,10 @@ static void PREFIX(_remove)(PREFIX(_table) *table, void *key) uint32_t hash = MAP_TABLE_HASH_KEY(key); PREFIX(_table_cell) baseCell = PREFIX(_table_lookup)(table, hash); - if (baseCell && baseCell < cell && cell - baseCell <= 32) + if (baseCell && baseCell != cell) { - uint32_t jump = 1 << (cell - baseCell - 1); + uint32_t displacement = (cell - baseCell + table->table_size) % table->table_size; + uint32_t jump = 1 << (displacement - 1); if ((baseCell->secondMaps & jump)) { // If we are removing a cell stored adjacent to its base due to hash