Skip to content

Repair lock-free queue correctness and reclamation - #11

Merged
darkautism merged 6 commits into
HPfrom
fix/lockfree-correctness
Sep 26, 2026
Merged

darkautism merged 6 commits into
HPfrom
fix/lockfree-correctness

Conversation

@darkautism

Copy link
Copy Markdown
Owner

Reworks the HP branch around a standard Michael-Scott queue publication protocol and fixes the correctness problems found during review.

Key changes:

  • link new nodes with CAS on tail->next before advancing tail
  • keep queue next and retired-list links separate
  • use atomic pointer/int operations on GCC/Clang and MSVC
  • protect dequeue head + successor with two hazard pointers
  • prevent reclamation while producers may hold stale local tail pointers
  • enforce hazard-slot ownership so manual and automatic dequeue cannot collide
  • fix max_consume_thread=0 default behavior, allocation/error handling, cleanup, invalid tids and reserved payload values
  • add status-returning dequeue APIs while keeping legacy wrappers
  • add edge/MPMC/ABA tests plus ASan/UBSan/TSan and MSVC CI
  • refresh Visual Studio project toolset and README

This intentionally keeps payload ownership with the caller; lfq_clean only reclaims queue nodes.

@darkautism
darkautism merged commit 5ec82ef into HP Sep 26, 2026
4 checks passed
@darkautism
darkautism deleted the fix/lockfree-correctness branch September 26, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant