Skip to content

ABA problem

Category: Hazards · Status: stub · Lessons: chapter 02, Shared state

One line: A compare-and-swap succeeds because a value changed from A to B and back to A, although what it stands for is no longer the same.

How it connects

flowchart LR
  n_aba_problem["ABA problem"]
  n_compare_and_swap["Compare-and-swap"]
  n_hazard_pointers["Hazard pointers"]
  n_race_condition["Race condition"]
  n_aba_problem -->|is a| n_race_condition
  n_compare_and_swap -->|can cause| n_aba_problem
  n_hazard_pointers -->|prevents| n_aba_problem
  classDef center stroke-width:3px
  class n_aba_problem center
  classDef outside stroke-dasharray: 4 3
  class n_compare_and_swap,n_hazard_pointers,n_race_condition outside

In each language

Java AtomicStampedReference keeps an integer stamp beside the reference, and its compareAndSet compares and sets both together

Where to read more