Tests: aim the failed page map at an address above user mode #3781

Open
BBareth wants to merge 1 commit from upstream-pr/3781 into main
BBareth commented 2026-12-03 09:29:17 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by BBareth on 2026-12-03T09:29:17Z.


an_address_keeps_the_page_the_title_mapped_there_last gets "an address with nothing reserved" by reserving 64 KiB and releasing it. A test running beside it can be given that address in between. The map then succeeds: it commits into that test's memory and copies a 64 KiB page over it. The kernelx test fails, and the other test can read memory that is gone, so the lib test process exits with 0xc0000005.

The map now aims at the first 64 KiB above lpMaximumApplicationAddress, where nothing can be reserved or committed.

Rebased onto main a815de93. main fixed the other test this PR first changed, a_page_whose_move_fails_stays_mapped_where_it_was, in e4c076ca (#3743) the same way, so this PR now changes only the map test and uses that commit's form.

What is in it

  • crates/xcl/src/hle/kernelx.rs (tests only): the failed map in an_address_keeps_the_page_the_title_mapped_there_last targets an address above user mode instead of a released reservation.

Tested

  • RTX 5070 Ti, driver 32.0.16.2124; i7-12700K; Windows 11 Pro 26200; rustc 1.95.0; debug suite, release smoke.
  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4 on 32f877bb (on main a815de93): 3018 passed, 0 failed, 56 ignored, 28 SKIPPED (22 no wave64, 2 no heap windows, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 driver cache).
  • cargo test -p xcl --lib kernelx -- --test-threads=4, 20 runs on 32f877bb: 19 passed. an_address_keeps_the_page_the_title_mapped_there_last failed in none. One run failed in a_page_leaving_plain_memory_has_the_tiles_over_it_linked_again, one of the tests that share kernelx's global page records without a common lock (not touched here).
  • Before the rebase (on main 16c2fd08, 30 runs each), the map test failed in 10 of 30 runs on main and 2 of 30 with this change's first form; with #3759's GPU test beside it, the lib tests crashed with 0xc0000005 in 3 of 61 runs, and in none of 40 with the fix.

Regression run
A test-only change; the runs are here for the check.

xcl-smoke v1
commit: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 120
exit: 0x0
frames shown: 3046 (PresentX 3046)
presents per 2 s (last 3): 15 27 19
device removals: 0
crashes: 0
peak commit: 32465 MB
xcl-smoke v1
commit: 32f877bbc883a235da8276d7002a5aa2271cb3fb
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 120
exit: 0x0
frames shown: 3037 (PresentX 3037)
presents per 2 s (last 3): 5 22 54
device removals: 0
crashes: 0
peak commit: 29457 MB

Each run follows one warm-up run of the same build; the A button is pressed once at 70 s.

Not tested

  • Whether this is the 0xc0000005 exit seen in some CI runs of the lib tests: those logs end at the crash without naming the test.
  • The other kernelx tests that share global page records still fail one another now and then in filtered runs. That is not fixed here.
  • AMD GPUs (the change touches no GPU path).

AI use

  • Claude Code, Claude Opus 5.5: found the race while chasing a crash in #3759's tests, wrote the change and its rebase, ran the loops, the suite and the regression runs, and wrote this description.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5623694586 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3781). Originally posted by [BBareth](https://github.com/BBareth) on 2026-12-03T09:29:17Z. --- `an_address_keeps_the_page_the_title_mapped_there_last` gets "an address with nothing reserved" by reserving 64 KiB and releasing it. A test running beside it can be given that address in between. The map then succeeds: it commits into that test's memory and copies a 64 KiB page over it. The kernelx test fails, and the other test can read memory that is gone, so the lib test process exits with `0xc0000005`. The map now aims at the first 64 KiB above `lpMaximumApplicationAddress`, where nothing can be reserved or committed. Rebased onto `main` a815de93. `main` fixed the other test this PR first changed, `a_page_whose_move_fails_stays_mapped_where_it_was`, in e4c076ca (#3743) the same way, so this PR now changes only the map test and uses that commit's form. **What is in it** - `crates/xcl/src/hle/kernelx.rs` (tests only): the failed map in `an_address_keeps_the_page_the_title_mapped_there_last` targets an address above user mode instead of a released reservation. **Tested** - RTX 5070 Ti, driver 32.0.16.2124; i7-12700K; Windows 11 Pro 26200; rustc 1.95.0; debug suite, release smoke. - `cargo build --workspace`, then `cargo test --workspace --no-fail-fast -- --test-threads=4` on 32f877bb (on main a815de93): 3018 passed, 0 failed, 56 ignored, 28 `SKIPPED` (22 no wave64, 2 no heap windows, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 driver cache). - `cargo test -p xcl --lib kernelx -- --test-threads=4`, 20 runs on 32f877bb: 19 passed. `an_address_keeps_the_page_the_title_mapped_there_last` failed in none. One run failed in `a_page_leaving_plain_memory_has_the_tiles_over_it_linked_again`, one of the tests that share kernelx's global page records without a common lock (not touched here). - Before the rebase (on main 16c2fd08, 30 runs each), the map test failed in 10 of 30 runs on main and 2 of 30 with this change's first form; with #3759's GPU test beside it, the lib tests crashed with `0xc0000005` in 3 of 61 runs, and in none of 40 with the fix. **Regression run** A test-only change; the runs are here for the check. ``` xcl-smoke v1 commit: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a gpu: NVIDIA GeForce RTX 5070 Ti title: 9cc6a39e seconds: 120 exit: 0x0 frames shown: 3046 (PresentX 3046) presents per 2 s (last 3): 15 27 19 device removals: 0 crashes: 0 peak commit: 32465 MB ``` ``` xcl-smoke v1 commit: 32f877bbc883a235da8276d7002a5aa2271cb3fb gpu: NVIDIA GeForce RTX 5070 Ti title: 9cc6a39e seconds: 120 exit: 0x0 frames shown: 3037 (PresentX 3037) presents per 2 s (last 3): 5 22 54 device removals: 0 crashes: 0 peak commit: 29457 MB ``` Each run follows one warm-up run of the same build; the A button is pressed once at 70 s. **Not tested** - Whether this is the `0xc0000005` exit seen in some CI runs of the lib tests: those logs end at the crash without naming the test. - The other kernelx tests that share global page records still fail one another now and then in filtered runs. That is not fixed here. - AMD GPUs (the change touches no GPU path). **AI use** - Claude Code, Claude Opus 5.5: found the race while chasing a crash in #3759's tests, wrote the change and its rebase, ran the loops, the suite and the regression runs, and wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Foniass commented 2026-12-03 09:30:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T09:30:39Z.


Review of 76fc17d7 (code reading only, not a merge-check) · no findings

In short: Test-only. Two kernelx tests got "an address with nothing reserved" by reserving one and releasing it, which races tests running beside them: the address can be handed out in between, and the map or move then commits and writes into another test's memory. Both now use 0x8000_0000_0000, above the user-mode range, where nothing can be reserved or committed. The fix is right, and nothing blocks it.

Checked and fine
  • 0x8000_0000_0000 is past the highest user-mode address on x64 Windows (0x7FFF_FFFE_FFFF), so no allocation can ever be placed there, and Wine's 47-bit user space ends at the same point.
  • MapTitlePhysicalPages and the page move try VirtualAlloc(at, MEM_COMMIT) first, and return null or fail when it fails, before any copy_nonoverlapping or write_bytes to at (kernelx.rs ~2585-2610). An unusable address is therefore never dereferenced; in_uma(at) is false there.
  • The assertions are unchanged: the map still returns null and leaves no entry, and the move still fails with the page kept where it was.
  • Tested shows the crash it fixes, 40/40 runs of the mapped filter with #3759's head, and says which other kernelx test failures remain and why.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7373773425 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3781#issuecomment-7373773425). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T09:30:39Z. --- **Review** of `76fc17d7` (code reading only, not a merge-check) · no findings **In short:** Test-only. Two `kernelx` tests got "an address with nothing reserved" by reserving one and releasing it, which races tests running beside them: the address can be handed out in between, and the map or move then commits and writes into another test's memory. Both now use `0x8000_0000_0000`, above the user-mode range, where nothing can be reserved or committed. The fix is right, and nothing blocks it. <details><summary>Checked and fine</summary> - `0x8000_0000_0000` is past the highest user-mode address on x64 Windows (`0x7FFF_FFFE_FFFF`), so no allocation can ever be placed there, and Wine's 47-bit user space ends at the same point. - `MapTitlePhysicalPages` and the page move try `VirtualAlloc(at, MEM_COMMIT)` first, and return null or fail when it fails, before any `copy_nonoverlapping` or `write_bytes` to `at` (`kernelx.rs` ~2585-2610). An unusable address is therefore never dereferenced; `in_uma(at)` is false there. - The assertions are unchanged: the map still returns null and leaves no entry, and the move still fails with the page kept where it was. - **Tested** shows the crash it fixes, 40/40 runs of the `mapped` filter with #3759's head, and says which other `kernelx` test failures remain and why. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
BBareth commented 2026-12-03 16:03:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by BBareth on 2026-12-03T16:03:57Z.


Rebased onto main a815de93 as 32f877bb. Main fixed the page-move test in e4c076ca (#3743), so this PR now changes only the failed map in an_address_keeps_the_page_the_title_mapped_there_last, using that commit's form (the first 64 KiB above lpMaximumApplicationAddress) instead of a constant.

Suite on 32f877bb: 3018 passed, 0 failed, 56 ignored, 28 SKIPPED. The kernelx filter ran 20 times with no failure of the map test. The smoke block in the description was rerun on this head.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7384196618 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3781#issuecomment-7384196618). Originally posted by [BBareth](https://github.com/BBareth) on 2026-12-03T16:03:57Z. --- Rebased onto main a815de93 as 32f877bb. Main fixed the page-move test in e4c076ca (#3743), so this PR now changes only the failed map in `an_address_keeps_the_page_the_title_mapped_there_last`, using that commit's form (the first 64 KiB above `lpMaximumApplicationAddress`) instead of a constant. Suite on 32f877bb: 3018 passed, 0 failed, 56 ignored, 28 SKIPPED. The kernelx filter ran 20 times with no failure of the map test. The smoke block in the description was rerun on this head. AI use: Claude Code (Claude Opus 5.5).
Foniass commented 2026-12-03 16:05:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T16:05:58Z.


Follow-up review of 32f877bb, since 76fc17d7 (code reading only, not a merge-check) · no new findings

In short: Rebased onto main a815de93. main already fixed the move test the same way in e4c076ca (#3743), so this PR now changes only an_address_keeps_the_page_the_title_mapped_there_last. It aims the failed map at the first 64 KiB above lpMaximumApplicationAddress, the form main uses, instead of a fixed 0x8000_0000_0000. Still right; nothing blocks it.

Checked and fine
  • (lpMaximumApplicationAddress + 1) rounded up to 64 KiB is 0x7FFF_FFFF_0000 on x64 Windows: the reserved no-access region past the last user address. VirtualAlloc with MEM_COMMIT fails there, so the map returns null before anything is copied, and no other test can be given that address. Reading the limit from GetSystemInfo also covers a different user-space size under Wine.
  • The form matches what e4c076ca put on main for a_page_whose_move_fails_stays_mapped_where_it_was, so the two tests now agree. The NO_USER_ADDRESS constant from the earlier head is gone with that test.
  • The assertions are unchanged: the failed map returns null and leaves no entry.
  • Tested gives the whole suite on 32f877bb (3018 passed, 0 failed, 56 ignored, 28 SKIPPED), and 20 runs of the kernelx filter with no failure in this test. It names the one unrelated flaky kernelx test, which shares the global page records.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7384257044 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3781#issuecomment-7384257044). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T16:05:58Z. --- **Follow-up review** of `32f877bb`, since `76fc17d7` (code reading only, not a merge-check) · no new findings **In short:** Rebased onto `main` `a815de93`. `main` already fixed the move test the same way in e4c076ca (#3743), so this PR now changes only `an_address_keeps_the_page_the_title_mapped_there_last`. It aims the failed map at the first 64 KiB above `lpMaximumApplicationAddress`, the form `main` uses, instead of a fixed `0x8000_0000_0000`. Still right; nothing blocks it. <details><summary>Checked and fine</summary> - `(lpMaximumApplicationAddress + 1)` rounded up to 64 KiB is `0x7FFF_FFFF_0000` on x64 Windows: the reserved no-access region past the last user address. `VirtualAlloc` with `MEM_COMMIT` fails there, so the map returns null before anything is copied, and no other test can be given that address. Reading the limit from `GetSystemInfo` also covers a different user-space size under Wine. - The form matches what e4c076ca put on `main` for `a_page_whose_move_fails_stays_mapped_where_it_was`, so the two tests now agree. The `NO_USER_ADDRESS` constant from the earlier head is gone with that test. - The assertions are unchanged: the failed map returns null and leaves no entry. - **Tested** gives the whole suite on `32f877bb` (3018 passed, 0 failed, 56 ignored, 28 SKIPPED), and 20 runs of the `kernelx` filter with no failure in this test. It names the one unrelated flaky `kernelx` test, which shares the global page records. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
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/3781:upstream-pr/3781'
git switch 'upstream-pr/3781'

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/3781'
git switch 'upstream-pr/3781'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3781'
git switch 'upstream-pr/3781'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3781'
git switch 'main'
git merge --squash 'upstream-pr/3781'
git switch 'main'
git merge --ff-only 'upstream-pr/3781'
git switch 'main'
git merge 'upstream-pr/3781'
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!3781
No description provided.