You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
slab::iterator copies the current 64-bit word (slab.cppm:288) and consumes bits from the copy. Later changes to that word are invisible:
Neighbour erased after the iterator was built: still set, ++it yields a destroyed slot.
Neighbour inserted after: not set, skipped. pool::erase then returns the wrong next.
multislab and pool iterators wrap it, so both inherit it.
Repro (confirmed)
libmem::pool<int, 64> p;
p.insert(1);
auto b = p.insert(2);
auto it = p.begin();
p.erase(b);
++it; // != end(), points at destroyed b
libmem::pool<int, 64> p;
auto a = p.insert(1);
p.insert(2);
p.erase(a); // returns end(), 2 is live
Fix
Store the bit index instead of the word. On increment, re-read slab_->bitmap_[word_idx_] and mask off bits <= bit_. Costs one L1 load per step. operator== compares indices; make_iterator(index) no longer pre-masks.
Tests
Both repros, with an element type that marks itself dead in its destructor.
Activity