Repository navigation
tests: never reuse an adapter sandbox's name within a test process - #1463
Merged
Pedro Henrique Penna (ppenna) merged 1 commit intoNov 10, 2026
Conversation
The Windows/WHP runtime adapter job of run 42896649941 failed before busy_root_fails_the_teardown started: Sandbox::new could not create its sandbox, ra-2012-3, "Access is denied. (os error 5)". Since 07d16d0, which dropped the scenario's name, Sandbox::new names each sandbox ra-PID-N after the first N that no directory takes, so each test of a binary takes 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 so failed 38 of 10,044 creations. 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 30 bytes short of the 55 that its sockets allow. 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 |
Pedro Henrique Penna (ppenna)
merged commit Nov 10, 2026
9298cd7
into
feature/nvx-refactor
85 of 87 checks passed
Pedro Henrique Penna (ppenna)
deleted the
agents/fix-adapter-sandbox-name-reuse
branch
November 10, 2026 23:43
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
The Windows/WHP runtime adapter job of run 42896649941 failed while
busy_root_fails_the_teardowncreated its sandbox, before it launchedanything:
Since 07d16d0 (#1432),
Sandbox::newnames each sandboxra-PID-Nafterthe first
Nthat no directory takes, so every test of a binary reuses thenames that the others free. Windows keeps the name of a directory that
remove_dir_allis deleting until the deletion completes, and until thenrefuses to create a directory under it with
ERROR_ACCESS_DENIED, notERROR_ALREADY_EXISTS, whichSandbox::newtakes for a failure. The race isintermittent: the job passed in the six runs of this branch between #1432 and
the failed one.
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. #1462 fixes
devthe same way,where sandbox names hold the scenario's name, so that only tests that share
one race.
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
ra-45856-0.tests/runtime-adapter/README.md: describes the new test.A test binary creates a few hundred sandboxes at most, so the counter adds at
most two digits to the short names of 07d16d0: with a seven-digit PID below
/tmp, the longest template store takes 25 of the 55 bytes that its clones'sockets allow.
Draft pull requests #1442, #1444, #1449, and #1458 carry a copy of
07d16d0, dc669fa, and so race the same way until they rebase onto this
fix.
Validation
On Windows 11 (NTFS), without a hypervisor:
threads that create and drop sandboxes through
common::Sandboxfor 20 s.With the
Sandbox::newof db39a5d, the run's head, 38 of 10,044 creationsfailed with the run's error; with the fix, 0 of 11,452.
cargo test --locked --features host --test sandbox_names, intests/runtime-adapter: failed before the fix, passed after it.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;and
cargo clippyandcargo 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 scripts/check_test_layout.pyandpython scripts/check_markdown_links.py: passed. This branch has noscripts/local_gates.py, so I ran the commands of the actions directly.Left to CI: the runtime adapter's VM scenarios on Windows/WHP, Linux/KVM, and
Linux/MSHV, including the job that failed; the guest-only build, tests, and
MSRV check on Linux; and the other gates of
check-nvx-rsandvalidate-nvx.python scripts/check_test_changes.py --base origin/feature/nvx-refactorlists one change to an 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.