Repository navigation
tests: never reuse an adapter sandbox's name within a test process - #1462
Merged
Pedro Henrique Penna (ppenna) merged 1 commit intoNov 10, 2026
Merged
Conversation
Sandbox::new names each sandbox runtime-adapter-NAME-PID-N after the first N that no directory takes, so tests that share a scenario name, such as the six of vm_clone that start clones named cl-r, take the names that the others free. Windows keeps the name of a directory that remove_dir_all deletes until the deletion completes, and until then refuses to create a directory under it with ERROR_ACCESS_DENIED, not ERROR_ALREADY_EXISTS, which Sandbox::new took for a failure: a test that took a name while another was removing the sandbox of that name panicked. On Windows, eight threads that create and remove sandboxes of one name failed 55 of 12,470 creations so. On feature/nvx-refactor, whose sandbox names leave out the scenario's name, the race failed the Windows/WHP runtime adapter job of run 42896649941. Number the sandboxes of a process from a counter instead, so that a process never takes the name of a sandbox that it created, and skips only the names that another process left. On Linux, the counter adds at most two digits, and with a seven-digit PID the longest template store below /tmp stays 6 bytes short of the 55 that its sockets allow, one byte less than before. The new sandbox_names test, which boots nothing, failed before the change, with the second sandbox at the name of the first. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
This pull request changes existing testsIt modifies or removes 1 existing test asset(s), listed below. Review each with care: a change to a test can hide a regression that the test caught. See doc/contribute.md#changes-to-existing-tests. Test code
Relocated unchanged: 0; added: 5. Compared the merge base |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the change to prevent sandbox-name reuse within a test process.
No open issues 🎉
What changed in this PR
This PR prevents runtime-adapter tests from reusing sandbox directory names within a test process, avoiding Windows access-denied failures while a previously used directory is still being deleted.
Changes:
- Allocate sandbox names using a process-wide atomic counter while preserving the name format and handling of existing directories.
- Add a host-only regression test that verifies a dropped sandbox’s name is not reused.
- Document the new regression test.
| File | Description |
|---|---|
tests/runtime-adapter/tests/sandbox_names.rs |
Adds a name-reuse regression test that requires no hypervisor. |
tests/runtime-adapter/tests/common/mod.rs |
Uses an atomic counter to assign distinct sandbox names within each process. |
tests/runtime-adapter/README.md |
Describes the new test and the Windows deletion race it guards against. |
Review effort: Balanced
Pedro Henrique Penna (ppenna)
deleted the
agents/check-related-issues-prs-nvx-ci
branch
November 10, 2026 23:33
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.
What and why
On Windows,
Sandbox::new, which creates the directory of each VM test of theruntime adapter, can panic with
Access is denied. (os error 5)before itstest launches anything. It names each sandbox
runtime-adapter-NAME-PID-Nafter the first
Nthat no directory takes, so tests that share a scenarioname reuse the names that the others free:
vm_cloneshares 15 names amongits 37 tests, such as
cl-r, which 6 of them use. Windows keeps the name of adirectory that
remove_dir_allis deleting until the deletion completes, anduntil then refuses to create a directory under it with
ERROR_ACCESS_DENIED,not
ERROR_ALREADY_EXISTS, whichSandbox::newtakes for a failure.On
feature/nvx-refactor, whose sandbox names leave out the scenario's namesince 07d16d0 (#1432), every test of a binary shares them, and the race
failed the Windows/WHP runtime adapter job of run 42896649941. CI
hasn't hit it on
dev: of the 9 Windows/WHP runtime adapter jobs that failedin the last 14 days, only that one failed this way.
#1463 fixes
feature/nvx-refactorthe same way.Each sandbox of a test process now takes
Nfrom a process-wide counter, so aprocess never takes the name of a sandbox that it created, while a name that
another process left still counts as taken. The directory's format stays as
it is.
tests/runtime-adapter/tests/common/mod.rs:Sandbox::newtakesNfromNEXT_SANDBOX.tests/runtime-adapter/tests/sandbox_names.rs: a new host-only test, whichboots nothing, drops a sandbox and checks that the next one of the same name
takes another name. Before the fix, both took
runtime-adapter-names-16820-0.tests/runtime-adapter/README.md: describes the new test.On Linux, the absolute path of a template store must stay within 55 bytes for
its clones' sockets,
generations/1/LAUNCH.sock, and within 56 for acapture's. A test binary creates a few hundred sandboxes at most, so the
counter adds at most two digits: with a seven-digit PID below
/tmp, thelongest template store grows from 48 to 49 bytes.
Validation
On Windows 11 (NTFS), without a hypervisor:
threads that create and drop sandboxes named
cl-rthroughcommon::Sandboxfor 20 s. Before the fix, 55 of 12,470 creations failed with
cannot create ...\runtime-adapter-cl-r-9668-1: Access is denied. (os error 5); after it,0 of 13,068.
cargo test --locked --features host --test sandbox_names, intests/runtime-adapter: failed before the fix, passed after it.python scripts/local_gates.py --base origin/dev --run --keep-going --only test-changes markdown-links test-layout nvx-rs-adapter-protocol nvx-rs-adapter-host: all 5 passed.tests/runtime-adapter, with Rust 1.95.0:cargo fmt --all --check;cargo clippy --locked --all-targets -- -D warnings,cargo build --locked,cargo test --locked, andRUSTDOCFLAGS="-D warnings" cargo doc --locked --no-deps, each also with--features host; andcargo clippyand
cargo docwith--features guest --target x86_64-unknown-linux-musl.With Rust 1.89,
cargo check --locked --all-targets, also with--features host. All passed.python -m unittest scripts.test_nvx_tools.RuntimeAdapterSuiteTests -v: 13passed.
Left to CI: the runtime adapter's VM scenarios on Windows/WHP, Linux/KVM, and
Linux/MSHV, which create their sandboxes through
Sandbox::new; theguest-only build, tests, and MSRV check on Linux; and the rest of the
nvx-rsand NVX CLI gates thatlocal_gates.pyselects, though this changesneither
nvx-rs/norscripts/.python scripts/check_test_changes.py --base origin/devlists one change toan existing test: the
Sandbox::newhelper intests/runtime-adapter/tests/common/mod.rs. It still creates a directory ofits own for each sandbox, skips a name that exists, and panics on any other
error; only its choice of
Nchanged, from the first number that nodirectory takes to the next of the process's counter. No assertion, timeout,
or ignored test changed.