Skip to content

fix(semaphore): defer waiter waker drops - #189

Merged
tisonkun merged 1 commit into
mainfrom
codex/semaphore-waker-safety
Aug 26, 2026
Merged

fix(semaphore): defer waiter waker drops#189
tisonkun merged 1 commit into
mainfrom
codex/semaphore-waker-safety

Conversation

@tisonkun

Copy link
Copy Markdown
Member

Summary

  • restore permits reserved by a canceled waiter before dropping its Waker
  • defer dropping a replaced Waker until after the waiters lock is released
  • cover cancellation ordering with a regression test using the public semaphore API

The ordering matters because a custom RawWaker drop callback may panic or re-enter semaphore code. Keeping those callbacks outside the critical section also matches the deferred-drop convention used by the other internal synchronization primitives.

Testing

  • cargo x lint
  • cargo x test --no-capture

@tisonkun
tisonkun merged commit a3bad1c into main Aug 26, 2026
9 checks passed
@tisonkun
tisonkun deleted the codex/semaphore-waker-safety branch August 26, 2026 01:23
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