Correct CAS Still Crashes
Node* pop() {
Node* old = head.load(std::memory_order_acquire);
while (old && !head.compare_exchange_weak(old, old->next,
std::memory_order_acquire,
std::memory_order_relaxed)) {
// retry
}
if (old) delete old; // caller already copied the value out
return old;
}
Assume ABA has been eliminated: head now packs a modification counter next to the address, with the tag arithmetic elided from the snippet, and ThreadSanitizer reports no data race on head. At 16 threads the program still faults intermittently while evaluating the old->next argument. What is missing?
Sign in to answer questions and track your progress
Sign In