ABA problem
Appearance
The ABA problem occurs when multiple threads (or processes) accessing shared memory interleave. Below is the sequence of events that will result in the ABA problem:
- Process reads value A from shared memory,
- is preempted, allowing process ,
- modifies the shared memory value A to value B and back to A before preemption,
- begins execution again, sees that the shared memory value has not changed and continues.
Although can continue executing, it is possible that the behavior will not be correct due to the "hidden" modification in shared memory.
References
- Damian Dechev, Peter Pirkelbauer, and Bjarne Stroustrup. Lock-free Dynamically Resizable Arrays