Tests: a page's failed move goes to an address Windows never hands out #2773

Open
github-bot wants to merge 1 commit from github-bot/gh-2773 into nvidia-dev AGit
Owner

@⁠inf1425 on GitHub · 2026-11-26 11:38 UTC · original
inf1425:tests/kernelx-move-fails-unreservable-address → nvidia-dev · +6 −3 · 1 files · 1 commits · draft

a_page_whose_move_fails_stays_mapped_where_it_was gets "an address with nothing reserved" for its move by reserving a page and releasing it again. With tests running on other threads, Windows can give that address to one of them before the move. The commit then succeeds and the test fails at move_away(..).is_err(). Worse, the move writes this test's page into the other test's reservation. In one parallel run, a_page_leaving_plain_memory_has_the_tiles_over_it_linked_again read 7, this test's value, where it had written 0xA. The destination is now the first page past the user address space. Committing there always fails, and Windows never gives that address to anyone. Found while checking the nvidia-dev test failures reported in #42.

What is in it

  • crates/xcl/src/hle/kernelx.rs (in mod tests): the destination is GetSystemInfo's lpMaximumApplicationAddress + 1, rounded up to 64 KiB. Test code only; windows-sys already has the Win32_System_SystemInformation feature.

Tested

  • NVIDIA GeForce RTX 4060 Laptop GPU (8 GB, driver 616.64), Ryzen 7 7840HS, Windows 11 build 26300, Rust 1.95.0, debug build.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 at this PR's head: 1745 passed, 5 failed, 48 ignored. The 5 failures are the ones reported in #42: four are fixed by #2770 and #2771, and the mesh test is in #2632.
  • SKIPPED GPU tests (26): 21 need wave64; 3 are f16 ops the per-lane form refuses (#1426); 2 need XCL_HEAP_WINDOWS=1.
  • cargo test -p xcl --lib hle::kernelx -- --test-threads=4, repeated:
    • unmodified: this test failed 6 times in 40 runs;
    • this PR: it did not fail in 60 runs. One other test failed once (an_address_keeps_the_page_the_title_mapped_there_last); that is the release race #2772 fixes;
    • with #2772 as well: 0 failures in 100 runs.

Regression run

  • The change is inside #[cfg(test)] mod tests and never reaches xcl.exe, but scripts/pr_check.py counts any file under crates/xcl/src/ as runtime. Smoke blocks from nvidia-dev and from this head will be added once a title is available, unless a maintainer prefers the test-only label.

main:

PR:

Not tested

  • AMD, other NVIDIA cards, Linux/Wine, a release build, any retail title.

AI use

  • Claude Code (Claude Opus 5.5) found the race and confirmed it from the other test's output, wrote the change and ran the tests. I read every line of the diff.
**@⁠inf1425** on GitHub · 2026-11-26 11:38 UTC · [original](https://github.com/xcl-dev/xcl/pull/2773) `inf1425:tests/kernelx-move-fails-unreservable-address` → `nvidia-dev` · +6 −3 · 1 files · 1 commits · draft `a_page_whose_move_fails_stays_mapped_where_it_was` gets "an address with nothing reserved" for its move by reserving a page and releasing it again. With tests running on other threads, Windows can give that address to one of them before the move. The commit then succeeds and the test fails at `move_away(..).is_err()`. Worse, the move writes this test's page into the other test's reservation. In one parallel run, `a_page_leaving_plain_memory_has_the_tiles_over_it_linked_again` read `7`, this test's value, where it had written `0xA`. The destination is now the first page past the user address space. Committing there always fails, and Windows never gives that address to anyone. Found while checking the `nvidia-dev` test failures reported in #42. **What is in it** - `crates/xcl/src/hle/kernelx.rs` (in `mod tests`): the destination is `GetSystemInfo`'s `lpMaximumApplicationAddress + 1`, rounded up to 64 KiB. Test code only; `windows-sys` already has the `Win32_System_SystemInformation` feature. **Tested** - NVIDIA GeForce RTX 4060 Laptop GPU (8 GB, driver 616.64), Ryzen 7 7840HS, Windows 11 build 26300, Rust 1.95.0, debug build. - `cargo test --workspace --no-fail-fast -- --test-threads=4` at this PR's head: 1745 passed, 5 failed, 48 ignored. The 5 failures are the ones reported in #42: four are fixed by #2770 and #2771, and the mesh test is in #2632. - SKIPPED GPU tests (26): 21 need wave64; 3 are f16 ops the per-lane form refuses (#1426); 2 need `XCL_HEAP_WINDOWS=1`. - `cargo test -p xcl --lib hle::kernelx -- --test-threads=4`, repeated: - unmodified: this test failed 6 times in 40 runs; - this PR: it did not fail in 60 runs. One other test failed once (`an_address_keeps_the_page_the_title_mapped_there_last`); that is the release race #2772 fixes; - with #2772 as well: 0 failures in 100 runs. **Regression run** - The change is inside `#[cfg(test)] mod tests` and never reaches `xcl.exe`, but `scripts/pr_check.py` counts any file under `crates/xcl/src/` as runtime. Smoke blocks from `nvidia-dev` and from this head will be added once a title is available, unless a maintainer prefers the `test-only` label. main: PR: **Not tested** - AMD, other NVIDIA cards, Linux/Wine, a release build, any retail title. **AI use** - Claude Code (Claude Opus 5.5) found the race and confirmed it from the other test's output, wrote the change and ran the tests. I read every line of the diff.
a_page_whose_move_fails_stays_mapped_where_it_was made its destination
"an address with nothing reserved" by reserving a page and releasing it
again. With tests on other threads, Windows can hand that address to one
of them before the move: the commit then succeeds, the test fails at
`move_away(..).is_err()`, and the move writes the page's bytes into the
other test's reservation (a_page_leaving_plain_memory_has_the_tiles_over_it_linked_again
then read 7, this test's value, where it had written 0xA - seen in a
parallel run of hle::kernelx).

The destination is now the first page past the user address space
(GetSystemInfo's lpMaximumApplicationAddress + 1, rounded up to 64 KiB):
committing there always fails, and no other test can be given it. Test
code only.

Assisted-by: Claude Code (Claude Opus 5.5)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:40:54 +00:00
Author
Owner

@⁠Prime1997 on GitHub · 2026-11-26 12:46 UTC · original · reviewed

Good within this test-only fix. The failed-move fixture now uses an address Windows cannot hand out, while preserving the assertion that the original page remains mapped. This avoids relying on another thread not reclaiming a released reservation.

Tested clean PR head 0c0a7aa4ef1c0ced8436ebfd9fdaf1c4182baf98, targeting current nvidia-dev af2cecc40886a8682ecf3267f5328c6dc4b66ad7, in its own worktree and build directory. 1 passed, 0 failed, 0 ignored, 0 skipped. Each filter ran in a fresh process:

  • hle::kernelx::tests::a_page_whose_move_fails_stays_mapped_where_it_was

Build: cargo test --locked --offline -p xcl --lib --no-run --message-format=json --target-dir <isolated-target>. Execution: <test-exe> <each-exact-name-above> --exact --test-threads=1 --nocapture. Only private executable/target paths are placeholders. Windows 11 Pro 26200, i5-10400, 32 GiB RAM, Rust 1.100.0 MSVC debug tests; no GPU calls in these selected fixtures.

Not tested: This is one owned-memory Windows fixture, not a concurrent stress run or proof of unrelated page-mapping paths. This supports retaining the PR; it is not whole-branch or merge certification.

AI use: Codex (GPT-6) reviewed source, ran the exact tests and checked the raw results. Optional temporary Discord for coordinating contributor work, testing and comparing results.

**@⁠Prime1997** on GitHub · 2026-11-26 12:46 UTC · [original](https://github.com/xcl-dev/xcl/pull/2773#pullrequestreview-6074362866) · **reviewed** **Good within this test-only fix.** The failed-move fixture now uses an address Windows cannot hand out, while preserving the assertion that the original page remains mapped. This avoids relying on another thread not reclaiming a released reservation. Tested clean PR head `0c0a7aa4ef1c0ced8436ebfd9fdaf1c4182baf98`, targeting current `nvidia-dev` `af2cecc40886a8682ecf3267f5328c6dc4b66ad7`, in its own worktree and build directory. **1 passed, 0 failed, 0 ignored, 0 skipped.** Each filter ran in a fresh process: - `hle::kernelx::tests::a_page_whose_move_fails_stays_mapped_where_it_was` Build: `cargo test --locked --offline -p xcl --lib --no-run --message-format=json --target-dir <isolated-target>`. Execution: `<test-exe> <each-exact-name-above> --exact --test-threads=1 --nocapture`. Only private executable/target paths are placeholders. Windows 11 Pro 26200, i5-10400, 32 GiB RAM, Rust 1.100.0 MSVC debug tests; no GPU calls in these selected fixtures. **Not tested:** This is one owned-memory Windows fixture, not a concurrent stress run or proof of unrelated page-mapping paths. This supports retaining the PR; it is not whole-branch or merge certification. AI use: Codex (GPT-6) reviewed source, ran the exact tests and checked the raw results. Optional temporary [Discord](https://discord.gg/gK3y7WRRY) for coordinating contributor work, testing and comparing results.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2773/head:github-bot/gh-2773'
git switch 'github-bot/gh-2773'

Merge

Merge the changes and update on Forgejo.
git switch 'nvidia-dev'
git merge --no-ff 'github-bot/gh-2773'
git switch 'github-bot/gh-2773'
git rebase 'nvidia-dev'
git switch 'nvidia-dev'
git merge --ff-only 'github-bot/gh-2773'
git switch 'github-bot/gh-2773'
git rebase 'nvidia-dev'
git switch 'nvidia-dev'
git merge --no-ff 'github-bot/gh-2773'
git switch 'nvidia-dev'
git merge --squash 'github-bot/gh-2773'
git switch 'nvidia-dev'
git merge --ff-only 'github-bot/gh-2773'
git switch 'nvidia-dev'
git merge 'github-bot/gh-2773'
git push origin 'nvidia-dev'
This discussion has been locked. Commenting is limited to contributors.
No description provided.