Tests: a failed page move commits nowhere another test can reserve (#1487) #1661

Open
Diskuss wants to merge 1 commit from upstream-pr/1671 into main
Diskuss commented 2026-11-24 19:06:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Diskuss on 2026-11-24T19:06:02Z.


hle::kernelx::tests::a_page_whose_move_fails_stays_mapped_where_it_was failed once in a parallel run (reported in #1487), with assertion failed: move_away(&mut away, old, at, page, false).is_err().

The cause: to get "an address with nothing reserved", the test reserves 64 KiB and releases it again. In a parallel run, another test can reserve that address before move_away runs. The MEM_COMMIT then succeeds, move_away copies the page's 64 KiB over the other test's memory, and returns Ok, so the assert fails. The other test's memory is also overwritten, which can make that test fail too.

What is in it

  • crates/xcl/src/hle/kernelx.rs, test module only: the destination is now 0xFFFF_8000_0000_0000, a kernel-space address. A commit there always fails, and no thread can reserve it. move_away itself is unchanged.

Tested

  • AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32015.7029; Ryzen 7 5700X3D (16 logical CPUs); Windows 11 Pro build 26300.9974; Rust 1.100.0 x86_64-pc-windows-msvc; debug.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on this head: 858 passed, 0 failed, 42 ignored, the same as main c160d86. 1 SKIPPED printed (heap_window_out_of_memory_falls_back_to_the_switch_form); 2 debug-layer tests skip silently (no Graphics Tools installed). No device removal.
  • With this change, the lib test binary run directly:
    • the test alone, 20 runs: 20 passed;
    • the full lib suite at --test-threads=16 (the default here), 22 runs: 22 × 809 passed, 0 failed.
  • On main c160d86, the failure is rare on this machine: 1 of 3 earlier cargo test --workspace runs at default threads (#1487). In today's runs: 0 of 20 with the test alone, 0 of 10 full-lib runs at 16 threads, and 0 of 30 full-lib runs at 32 threads. So the zero above shows that the change breaks nothing, but it does not prove the flake is gone. The cause above is from reading the code.

Regression run

  • Run and posted by Toons29 in this comment (not on our machine): scripts/smoke.ps1 on the retail title, 60 s, release build, XCL_NETWORK=0, AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0. Blocks copied unchanged: main on 4178e888, this PR on its head commit with no uncommitted changes.
xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 85a743fdb3861bd15b1f3bd32a30f2f0c0363dc9
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1632 (PresentX 1632)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14812 MB
  • Against the limits in CONTRIBUTING.md: 1632 against 1618 frames (101 %), 14812 against 14831 MB peak commit, 0 crashes, 0 device removals. The diff is inside #[cfg(test)] mod tests only, so this run only shows that the build is unaffected; it does not reach the changed test.

Not tested

  • Retail title / scripts/smoke.ps1 on our machine (no game files); the regression run above is Toons29's. NVIDIA and Intel (but see the RTX 3060 Ti cargo test -p xcl --lib result from DavidM1911 in the comments).

AI use

  • Claude Code (Claude Opus 5.5): code, tests and description; reviewed by Diskuss.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5478548831 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1671). Originally posted by [Diskuss](https://github.com/Diskuss) on 2026-11-24T19:06:02Z. --- `hle::kernelx::tests::a_page_whose_move_fails_stays_mapped_where_it_was` failed once in a parallel run (reported in #1487), with `assertion failed: move_away(&mut away, old, at, page, false).is_err()`. The cause: to get "an address with nothing reserved", the test reserves 64 KiB and releases it again. In a parallel run, another test can reserve that address before `move_away` runs. The `MEM_COMMIT` then succeeds, `move_away` copies the page's 64 KiB over the other test's memory, and returns `Ok`, so the assert fails. The other test's memory is also overwritten, which can make that test fail too. **What is in it** - `crates/xcl/src/hle/kernelx.rs`, test module only: the destination is now `0xFFFF_8000_0000_0000`, a kernel-space address. A commit there always fails, and no thread can reserve it. `move_away` itself is unchanged. **Tested** - AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32015.7029; Ryzen 7 5700X3D (16 logical CPUs); Windows 11 Pro build 26300.9974; Rust 1.100.0 x86_64-pc-windows-msvc; debug. - `cargo test --workspace --no-fail-fast -- --test-threads=4` on this head: 858 passed, 0 failed, 42 ignored, the same as main `c160d86`. 1 SKIPPED printed (`heap_window_out_of_memory_falls_back_to_the_switch_form`); 2 debug-layer tests skip silently (no Graphics Tools installed). No device removal. - With this change, the lib test binary run directly: - the test alone, 20 runs: 20 passed; - the full lib suite at `--test-threads=16` (the default here), 22 runs: 22 × 809 passed, 0 failed. - On main `c160d86`, the failure is rare on this machine: 1 of 3 earlier `cargo test --workspace` runs at default threads (#1487). In today's runs: 0 of 20 with the test alone, 0 of 10 full-lib runs at 16 threads, and 0 of 30 full-lib runs at 32 threads. So the zero above shows that the change breaks nothing, but it does not prove the flake is gone. The cause above is from reading the code. **Regression run** - Run and posted by Toons29 in [this comment](https://github.com/xcl-dev/xcl/pull/1671#issuecomment-7152051177) (not on our machine): `scripts/smoke.ps1` on the retail title, 60 s, release build, `XCL_NETWORK=0`, AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0. Blocks copied unchanged: `main` on `4178e888`, this PR on its head commit with no uncommitted changes. ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14831 MB ``` ``` xcl-smoke v1 commit: 85a743fdb3861bd15b1f3bd32a30f2f0c0363dc9 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1632 (PresentX 1632) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14812 MB ``` - Against the limits in CONTRIBUTING.md: 1632 against 1618 frames (101 %), 14812 against 14831 MB peak commit, 0 crashes, 0 device removals. The diff is inside `#[cfg(test)] mod tests` only, so this run only shows that the build is unaffected; it does not reach the changed test. **Not tested** - Retail title / `scripts/smoke.ps1` on our machine (no game files); the regression run above is Toons29's. NVIDIA and Intel (but see the RTX 3060 Ti `cargo test -p xcl --lib` result from DavidM1911 in the comments). **AI use** - Claude Code (Claude Opus 5.5): code, tests and description; reviewed by Diskuss. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
DavidM1911 commented 2026-11-24 21:30:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T21:26:36Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored.

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7144936168 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1671#issuecomment-7144936168). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T21:26:36Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~22 ignored. Thanks!
Toons29 commented 2026-11-25 04:10:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T03:35:08Z.


Regression run of 85a743fd on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 85a743fdb3861bd15b1f3bd32a30f2f0c0363dc9
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1632 (PresentX 1632)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14812 MB

Against the limits in CONTRIBUTING.md: 101 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7152051177 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1671#issuecomment-7152051177). Originally posted by [Toons29](https://github.com/Toons29) on 2026-11-25T03:35:08Z. --- Regression run of `85a743fd` on the retail title, for this PR's **Regression run** section. Both blocks are from `scripts/smoke.ps1` as printed, not edited: `main` on `4178e888`, this PR on its head commit with no uncommitted changes, same title and time. ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14831 MB ``` ``` xcl-smoke v1 commit: 85a743fdb3861bd15b1f3bd32a30f2f0c0363dc9 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1632 (PresentX 1632) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14812 MB ``` Against the limits in CONTRIBUTING.md: 101 % of `main`'s frames, 100 % of its peak commit, no crash, no device removal. AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; I checked the blocks before posting.
github-actions[bot] commented 2026-11-29 20:41:24 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:41:24Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7262280000 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1671#issuecomment-7262280000). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T20:41:24Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 06:27:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:27:43Z.


Triage (#1607) – head 85a743f

#2773 (draft, opened later) makes the same fix to a_page_whose_move_fails_stays_mapped_where_it_was. Both PRs stop reserving and releasing a scratch address that another test thread could reserve before move_away commits there. #2773 uses the first 64 KiB page past lpMaximumApplicationAddress; this PR uses the kernel-space address 0xFFFF_8000_0000_0000. Either way the MEM_COMMIT in move_away fails as the test expects. This PR was first, and its description has the test runs and a regression run.
#1520, #1600 and #1628 are other #1487 flakes and do not overlap.
No problems found in the diff. It is still a draft.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7302897780 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1671#issuecomment-7302897780). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:27:43Z. --- **Triage (#1607)** – head 85a743f #2773 (draft, opened later) makes the same fix to `a_page_whose_move_fails_stays_mapped_where_it_was`. Both PRs stop reserving and releasing a scratch address that another test thread could reserve before move_away commits there. #2773 uses the first 64 KiB page past lpMaximumApplicationAddress; this PR uses the kernel-space address 0xFFFF_8000_0000_0000. Either way the MEM_COMMIT in move_away fails as the test expects. This PR was first, and its description has the test runs and a regression run. #1520, #1600 and #1628 are other #1487 flakes and do not overlap. No problems found in the diff. It is still a draft. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Kalmarv commented 2026-12-02 23:42:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T23:42:35Z.


CI evidence for this fix: job 143772436418 (pr/resource-creation-fallbacks, 2026-12-02), which does not touch kernelx, failed with assertion failed: move_away(&mut away, old, at, page, false).is_err() in a_page_whose_move_fails_stays_mapped_where_it_was. That is the failure this PR describes: another test thread's first-fit VirtualAlloc took the address the test had released, so the commit succeeded. It was the only failure of that kind in a survey of the 60 most recent failed Build and test (Windows, no GPU) runs.

Written with Claude Code (Claude Opus 5.5) from the CI logs.

<!-- greyfinch-sync:ivall/xcl:comment:7362331120 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1671#issuecomment-7362331120). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T23:42:35Z. --- CI evidence for this fix: job [143772436418](https://github.com/xcl-dev/xcl/actions/runs/46967481763/job/143772436418) (`pr/resource-creation-fallbacks`, 2026-12-02), which does not touch `kernelx`, failed with `assertion failed: move_away(&mut away, old, at, page, false).is_err()` in `a_page_whose_move_fails_stays_mapped_where_it_was`. That is the failure this PR describes: another test thread's first-fit `VirtualAlloc` took the address the test had released, so the commit succeeded. It was the only failure of that kind in a survey of the 60 most recent failed `Build and test (Windows, no GPU)` runs. Written with Claude Code (Claude Opus 5.5) from the CI logs.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1671:upstream-pr/1671'
git switch 'upstream-pr/1671'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1671'
git switch 'upstream-pr/1671'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1671'
git switch 'upstream-pr/1671'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1671'
git switch 'main'
git merge --squash 'upstream-pr/1671'
git switch 'main'
git merge --ff-only 'upstream-pr/1671'
git switch 'main'
git merge 'upstream-pr/1671'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1661
No description provided.