Learn the vocabulary of publishing a pointer before dereferencing it so reclaiming threads can check and defer freeing it safely.
0 / 5 completed
1 / 5
A teammate explains that before dereferencing a shared pointer in a lock-free structure, a thread first publishes that pointer into a per-thread slot visible to all other threads, so a thread attempting to reclaim that node can check the slots and defer freeing it until no thread has it published. What memory-safety technique is being described?
Hazard pointers are exactly this: before dereferencing a shared pointer, a thread publishes it into a per-thread hazard-pointer slot visible to every other thread, and a thread attempting to reclaim a node scans all hazard-pointer slots and defers freeing that node until no slot references it, guaranteeing no thread is caught mid-dereference of memory about to be freed. A DNS zone transfer is an unrelated concept about replicating name server records. This publish-then-check-before-reclaiming approach is exactly why hazard pointers are used to safely reclaim memory in lock-free data structures with a bounded per-node overhead.
2 / 5
During a design review, the team adopts hazard pointers for a lock-free queue, specifically so a node can be safely reclaimed as soon as no thread's hazard-pointer slot references it, without needing a global epoch that waits for every thread to advance. Which capability does this provide?
Hazard pointers here provide fine-grained, per-node reclamation safety independent of slow or stalled threads, since only the specific threads currently referencing a node need to clear it, rather than waiting for every thread in the system to advance a shared epoch, which a single stalled thread could otherwise delay indefinitely. Epoch-based reclamation ties every node's reclamation to the slowest thread's epoch advancement, which is a different tradeoff. This check-only-the-threads-that-matter behavior is exactly why hazard pointers can reclaim memory promptly even when one thread is stalled.
3 / 5
In a code review, a dev notices a lock-free queue frees a node as soon as it is unlinked, with no per-thread published-pointer mechanism to check whether another thread is mid-dereference of that exact node. What does this represent?
This is a missed hazard-pointer requirement, since publishing and checking hazard pointers before reclaiming would prevent freeing a node another thread is actively dereferencing. A cache eviction policy is an unrelated concept about discarded cache entries. This no-published-pointer-check pattern is exactly the kind of use-after-free hazard a reviewer flags once a lock-free structure reclaims memory concurrently with readers.
4 / 5
An incident report shows a lock-free queue crashed with a use-after-free because a node was freed the instant it was unlinked, while another thread was still dereferencing that exact node with no hazard-pointer mechanism to detect and prevent the premature free. What practice would prevent this?
Adopting hazard pointers lets a thread publish the node it is dereferencing, and the reclaiming thread checks those published slots before freeing it, preventing the premature free. Continuing to free a node the instant it is unlinked regardless of whether any other thread is still dereferencing it is exactly what caused the crash described in this incident. This publish-then-check-before-reclaiming approach is the standard fix once premature frees are confirmed to race with concurrent dereferences.
5 / 5
During a PR review, a teammate asks why the team reaches for hazard pointers instead of epoch-based reclamation, given that both are established techniques for safely freeing memory in lock-free structures. What is the reasoning?
Hazard pointers reclaim a node as soon as the specific threads referencing it clear their slots, avoiding delay from a slow unrelated thread, while epoch-based reclamation is simpler to reason about globally but can delay reclamation for every node until the slowest thread advances its epoch. This is exactly why hazard pointers are favored when a single stalled thread must not be allowed to block reclamation of unrelated nodes, while epoch-based reclamation remains attractive for its simpler global bookkeeping when stalls are rare.