Skip to content

Commit 211823e

Browse files
committed
Fix dict race condition
1 parent 72570c5 commit 211823e

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

crates/vm/src/dict_inner.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,9 +603,13 @@ impl<T: Clone> Dict<T> {
603603
let ret = 'outer: loop {
604604
let (entry_key, ret) = {
605605
let inner = lock.take().unwrap_or_else(|| self.read());
606-
let idxs = idxs.get_or_insert_with(|| {
607-
GenIndexes::new(hash_value, (inner.indices.len() - 1) as i64)
608-
});
606+
let mask = (inner.indices.len() - 1) as i64;
607+
let idxs = idxs.get_or_insert_with(|| GenIndexes::new(hash_value, mask));
608+
if idxs.mask != mask {
609+
// Dict was resized since last probe, restart
610+
*idxs = GenIndexes::new(hash_value, mask);
611+
free_slot = None;
612+
}
609613
loop {
610614
let index_index = idxs.next();
611615
let index_entry = *unsafe {

0 commit comments

Comments
 (0)