Repository navigation
test: verify waker contract boundaries in Latch and Barrier - #499
Open
nanami-0713 wants to merge 1 commit into
Open
nanami-0713 wants to merge 1 commit into
nanami-0713 wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LatchandBarrierwake waiters and destroy replaced or cancelled wakers outside their waiter locks, but no test guarded those boundaries: with all six wake and drop sites moved back under the lock, the pre-existingLatchandBarriertests still passed.LatchandBarrierfrom wake and waker-drop callbacks and that re-poll with a new waker to check the replaced waker is released. The existingBarriergeneration tests now also assert that followers are woken before they are polled.#[cfg(test)]probe for theLatchzero transition. TerminalLatchwaits are lock-free, so a public-API re-entry cannot tell whetherwake_allruns under the waiter lock; the probe usestry_lockinside the wake callback, like theCompletionprobe in test(completion): verify wake callbacks run outside waiter lock #482.Production code is unchanged.
Validation
Local validation on macOS (
aarch64-apple-darwin, stablerustc 1.99.1, nightly1.102.0-nightlyfrom 2026-11-08):cargo x checkcargo x test— 788 tests passed, including 177 doc testscargo x lint— clippy, taplo, typos, hawkeye, and the docsrs rustdoc check pass. The rustfmt step stops on two doc-comment diffs inasyncband/src/mpsc/bounded/receiver.rs, which is unchanged here and shows the same diffs onmain(b6b8adf) with this nightly; the files touched by this PR are rustfmt-clean.cargo x miri— 574 tests passed; 14 existing tests are ignored under MiriMutation checks in a temporary source copy, each moving one site back under the lock:
Latch::arrivewakes under the waiter locklatch::tests::arrive_wakes_outside_waiter_lockLatchdrops the replaced waker under the waiter locklatch_test::waker_callbacks_can_reenter_the_latchLatchdrops the cancelled waker under the waiter locklatch_test::waker_callbacks_can_reenter_the_latchBarrierdrops the replaced waker under the barrier lockbarrier_test::wake_and_waker_destruction_happen_outside_the_barrier_lockBarrierleader wakes followers under the barrier lockbarrier_test::wake_and_waker_destruction_happen_outside_the_barrier_lockBarrierdrops the cancelled waker under the barrier lockbarrier_test::wake_and_waker_destruction_happen_outside_the_barrier_lockEach mutation failed exactly one test and nothing else. With all six mutations applied together and the pre-PR
latch_testandbarrier_testrestored in place of the new ones, the remainingBarrierunit test and the 21 integration tests inlatch_test,barrier_test, andshutdown_teststill passed.