Apex › Systems & OS

The ABA problem

The subtle bug that makes lock-free programming hard. Compare-and-swap checks that a value is the same, not that it never changed — so if another thread cycles it A → B → A while you're preempted, your CAS is fooled into succeeding on a world that moved underneath it, splicing a freed node back into a stack. Toggle a plain CAS versus a versioned (tagged) CAS and watch one corrupt and the other stay safe.

More in Systems & OS