allocator is subject to ABA problem
Lingxi-Li opened this issue · 0 comments
Lingxi-Li commented
For example, allocator::allocate()
is currently implemented as
T* allocate(std::size_t = 1) {
auto oldhead = head.load(acq);
do {
if (!oldhead) throw std::bad_alloc{};
}
while (!head.compare_exchange_weak(oldhead, oldhead->next, rlx, acq));
return std::addressof(oldhead->data);
}
When head
compares equal to oldhead
, oldhead->next
may already be outdated and invalid.