Repository navigation
Launch-slot test: wait for a released slot a forked child may still hold - #52
Merged
Merged
Conversation
…es at once launches_wait_for_a_free_slot dropped its two slots and took one with no patience. A slot is a flock on an open file description: when another test thread forks between the slot's open and its release, the child holds a copy of the descriptor, and so the lock, until it execs (the descriptor is O_CLOEXEC). The lock outlived the drop and the test failed. The test now forks such a child itself (one pausing in pre_exec) while it releases the slots, which made the old assertion fail every time, and waits up to 10 s for the slot. Production keeps the flock: a slot held a few milliseconds longer only delays one launch, fcntl locks wouldn't exclude threads of one process, and macOS has no OFD locks. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The inherited-lock test can pass without exercising child-held descriptors because its pre-fork notification and fixed sleep do not reliably synchronize the parent and child.
1 open issue
What changed in this PR
Updates the CLI browser launch-slot test to tolerate locks briefly retained by forked children, addressing intermittent macOS CI failures without changing the production gate.
Changes:
- Adds a Unix helper that delays child execution to exercise descriptor inheritance.
- Allows up to 10 seconds for slot reacquisition and verifies both slots are held before testing cancellation.
| File | Description |
|---|---|
packages/cli/src/browser/tests.rs |
Adds fork-delay coverage and bounded waits for released launch slots. |
Review effort: Balanced
…ps the slots From review: the child's 50 ms head start didn't establish that it held the slot descriptors when the slots were dropped. ForkedChild now signals from pre_exec through a pipe once forked and waits on a second pipe to exec, so the test asserts the dropped slots stay locked while the child holds them, then lets it exec and waits for a slot. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

Fixes the
browser::tests::launches_wait_for_a_free_slotflake (cli/src/browser/tests.rs:56, "assertion failed: gate::acquire_in(…, Duration::ZERO).unwrap().held()"). It failedpublic-product (macos-latest)on #46 and #48.Root cause
A launch slot is a
flockon an open file description. Rust already opens the slot filesO_CLOEXEC, but when another test thread forks while a slot is held, the child gets a copy of the descriptor. It keeps the lock until it execs. The test dropped its slots and immediately tried to take one with zero patience, so a fork in that window left both slots locked.Fix
The fix is in the test, not the gate:
launches_wait_for_a_free_slotnow reproduces the race deterministically.forking_childspawnstrueon another thread with a 300 ms pause inpre_exec, and the test releases the slots while that child holds their descriptors.Production keeps
flock:fcntllocks aren't inherited, but they don't exclude two threads of one process, and they drop on any close of the file.Checks
cargo test -p projections-cli --lib browser::: 7/7, five runs-D warningsand the Windows-targetcargo check --all-targets: cleantools check --fast: clean