Two entries in this site's Concurrency category were built to close the exact same unfinished business: the Treiber Stack's own Pitfalls section names "hazard pointers and epoch-based reclamation" as the two standard fixes for its ABA problem, then builds neither. Hazard Pointers and Epoch-Based Reclamation are those two fixes, each raced against the identical Minimal/Larger scenarios and Recycle/Fresh-ids allocators the Treiber Stack's own page already measured corrupting it. Picking between them isn't a question of which one actually works — both do, completely — it's a question of which real cost, already measured on each page, you'd rather carry.
The Treiber Stack's own unprotected baseline corrupts 1 of 59 reachable states in the Minimal/Recycle configuration and 3 of 179 in Larger/Recycle. Hazard Pointers' Guarded variant and Epoch-Based Reclamation's Correct variant each hold at 0 corrupt states across all eight configurations either page tests (two scenarios × two allocators each) — not a near-miss or a probabilistic improvement, a complete closure of every corrupting schedule each page's own exhaustive search can reach. Neither page is "the right one" with the other a cheaper shortcut that happens to also pass; both are fully correct protocols that solve the problem in structurally different ways, which is exactly why their costs diverge once something actually goes wrong rather than just differing by degree on the same failure.
Each page's own reachable-state count gives a rough, honest sense of how much extra bookkeeping each protocol adds over the Treiber Stack's own unprotected baseline — a state-space measurement, not a wall-clock one, as both pages are careful to say about their own numbers:
| Minimal / Recycle | Larger / Recycle | |
|---|---|---|
| Treiber Stack (unprotected baseline) | 59 states | 179 states |
| Hazard Pointers (Guarded) | 107 states (+81%) | 353 states (+97%) |
| Epoch-Based Reclamation (Correct) | 80 states (+36%) | 312 states (+74%) |
Epoch-Based Reclamation's own page already draws this comparison and attributes the gap to a
structural difference, not an accident of either implementation: pinning a thread for its whole
operation is one interleavable sub-step, where Hazard Pointers' publish-then-validate is two. On
the healthy path neither reference implementation shortcuts the other kind of work, though — Hazard
Pointers' scanAndReclaim and Epoch-Based Reclamation's tryAdvanceAndReclaim
both run unconditionally on every single successful pop in each page's own pseudocode, an
O(threads) check either way. The state-space gap above is real, but it's bookkeeping
overhead, not a difference in which operations pay a cost at all.
This is where the two schemes actually separate, and it's the one cost neither page's healthy-path numbers show. Hazard Pointers tracks individual node identity: a stalled thread occupies exactly one shared hazard slot, so it can hold at most the one id it last published hostage — bounded by construction, for as long as the stall lasts, no matter how much unrelated work every other thread gets done in the meantime. Epoch-Based Reclamation tracks thread liveness instead, and its own Pitfalls section measures what that costs when a thread pins and never unpins: the global epoch freezes at whatever value that thread pinned at, and every node any other thread retires from that moment on piles onto the shared retired list with no path to ever being freed. The page's own live widget measures this directly rather than asserting it — the stuck-node count comes out exactly equal to however many push/pop cycles the other thread runs while the first stays pinned: 10 cycles, 10 stuck nodes; 1,000 cycles, 1,000 stuck nodes. A 1:1 rate, unbounded in principle, against Hazard Pointers' flat bound of one.
The real question this guide answers, then, isn't "which scheme is more correct" — it's "can a thread in this system pin (or hold a hazard) and then genuinely stall for a long, unbounded time — crash, get killed, deadlock elsewhere, a long GC pause, OS preemption under heavy contention — without anything detecting or restarting it?" If the answer is yes, and a hard bound on how much memory one stuck thread can hold hostage actually matters, Hazard Pointers gives you that bound structurally, at the cost of the heavier per-operation bookkeeping measured above. If the answer is no — threads either keep moving or get noticed and recovered quickly — Epoch-Based Reclamation's cheaper bookkeeping is the better default, since the failure mode that makes it expensive will rarely, if ever, actually run.
Both pages flag, in their own words, that the "scan on every retire" cost measured above is this site's own simplified model, not what a tuned real-world implementation does. Hazard Pointers' own Pitfalls section: production implementations "batch scans (reclaim in bulk once a retired list crosses some threshold, rather than on every single retire)." Epoch-Based Reclamation's own Reference implementation section: production implementations "bucket retired nodes by the epoch they were retired in, so an eligible batch is freed by discarding a whole bucket at once" instead of scanning the whole list. Both notes matter for the same reason, and neither changes the decision above: batching and bucketing both amortize the healthy-path scan cost, but neither touches what each scheme tracks in the first place. The stalled-thread asymmetry comes from tracking a node id versus tracking a thread's liveness, not from how eagerly either implementation frees memory — it survives into any production tuning of either scheme untouched.
| Scheme | Tracks | Reachable-state overhead vs. baseline | Single stalled thread holds hostage | Reach for it when |
|---|---|---|---|---|
| Hazard Pointers | one node id per thread, published before every dereference | +81% (Minimal) / +97% (Larger) | exactly 1 node, no matter how long the stall lasts | a thread can stall unpredictably for a long or unbounded time, and a hard bound on memory held hostage matters more than per-op bookkeeping cost |
| Epoch-Based Reclamation | whether each thread is active, not which node it's touching | +36% (Minimal) / +74% (Larger) | every node retired by every other thread since the stall began — unbounded, measured 1:1 | threads reliably keep moving or get detected and recovered quickly, so the unbounded case rarely runs |