xmem tests take the per-page path again; a reservation shown whole has its own test #16

Open
github-bot wants to merge 1 commit from github-bot/gh-16 into main AGit
Owner

@⁠Ekabusto on GitHub · 2026-11-25 11:59 UTC · original
Ekabusto:fix/xmem-tests-per-page-path → main · +73 −13 · 1 files · 1 commits · open

Fixes the five xmem failures in #2 and #8, following the first of the two ways out proposed in #2: keep map_whole and point the old tests back at the path they were written for.

Cause

Since map_whole (fa07481), a reservation as long as the section of the pages mapped into it is shown whole by one view, and unmapping inside it changes nothing. Five tests reserved exactly as many pages as they allocated, so they took that path, then found an unmapped page still committed (MEM_COMMIT 0x1000 where MEM_RESERVE 0x2000 was expected).

Change (crates/victory-hle/src/modules/xmem.rs only)

  • physical_pages_map_alias_and_unmap, mapping_no_pages_changes_nothing and pages_and_reservation (used by the four a_run_*/a_failed_run_* tests) allocate one page more than the reservation holds, so mappings go page by page. Their assertions are unchanged.
  • New a_reservation_is_shown_whole: a 3-page reservation mapped in three calls is one view of 3 pages; pages land where they are first put (pages 1 and 2 swapped, checked through page_bytes); unmapping a page leaves it shown; map_alias into it is refused.
  • map_alias with len == 0 returns true before the in_whole check. This is the one non-test change. in_whole(base, 0) is true when base is the start of a reservation shown whole, so mapping_no_pages_changes_nothing's probe "past the view" (a + 2 pages) was refused about 1 run in 20 whenever the new test's reservation happened to follow its own. A copy of no bytes now changes nothing anywhere, the same way unmap already returns early for len == 0. For len > 0 nothing changes.

Checks (Windows 11 build 26300, Rust 1.98.1, no game data)

  • cargo test --locked -p victory-hle --lib xmem: 15 passed, 0 failed, 100 runs in a row. On main (71652a2): 9 passed, 5 failed.
  • cargo test --locked -p victory-hle --lib: 103 passed, 1 ignored.
  • cargo fmt --check and cargo clippy -p victory-hle --all-targets -- -D warnings report only what they report on main (rustfmt line wrapping in map_whole/map_alias, clippy's items_after_test_module); nothing new from this change.

Not checked: the game. The map_alias change only affects zero-length copies; I don't know whether the GPU queue ever issues one into the whole-shown heap, but if it did it was refused (with a warning) before and is a no-op now.

AI-assisted (Claude Code); no game data.

🤖 Generated with Claude Code

**@⁠Ekabusto** on GitHub · 2026-11-25 11:59 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/16) `Ekabusto:fix/xmem-tests-per-page-path` → `main` · +73 −13 · 1 files · 1 commits · open Fixes the five `xmem` failures in #2 and #8, following the first of the two ways out proposed in #2: keep `map_whole` and point the old tests back at the path they were written for. ## Cause Since `map_whole` (`fa07481`), a reservation as long as the section of the pages mapped into it is shown whole by one view, and unmapping inside it changes nothing. Five tests reserved exactly as many pages as they allocated, so they took that path, then found an unmapped page still committed (`MEM_COMMIT` 0x1000 where `MEM_RESERVE` 0x2000 was expected). ## Change (`crates/victory-hle/src/modules/xmem.rs` only) - `physical_pages_map_alias_and_unmap`, `mapping_no_pages_changes_nothing` and `pages_and_reservation` (used by the four `a_run_*`/`a_failed_run_*` tests) allocate one page more than the reservation holds, so mappings go page by page. Their assertions are unchanged. - New `a_reservation_is_shown_whole`: a 3-page reservation mapped in three calls is one view of 3 pages; pages land where they are first put (pages 1 and 2 swapped, checked through `page_bytes`); unmapping a page leaves it shown; `map_alias` into it is refused. - `map_alias` with `len == 0` returns `true` before the `in_whole` check. **This is the one non-test change.** `in_whole(base, 0)` is true when `base` is the start of a reservation shown whole, so `mapping_no_pages_changes_nothing`'s probe "past the view" (`a + 2 pages`) was refused about 1 run in 20 whenever the new test's reservation happened to follow its own. A copy of no bytes now changes nothing anywhere, the same way `unmap` already returns early for `len == 0`. For `len > 0` nothing changes. ## Checks (Windows 11 build 26300, Rust 1.98.1, no game data) - `cargo test --locked -p victory-hle --lib xmem`: 15 passed, 0 failed, **100 runs in a row**. On `main` (`71652a2`): 9 passed, 5 failed. - `cargo test --locked -p victory-hle --lib`: 103 passed, 1 ignored. - `cargo fmt --check` and `cargo clippy -p victory-hle --all-targets -- -D warnings` report only what they report on `main` (rustfmt line wrapping in `map_whole`/`map_alias`, clippy's `items_after_test_module`); nothing new from this change. **Not checked:** the game. The `map_alias` change only affects zero-length copies; I don't know whether the GPU queue ever issues one into the whole-shown heap, but if it did it was refused (with a warning) before and is a no-op now. AI-assisted (Claude Code); no game data. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Since map_whole (fa07481), a reservation as long as the section of the
pages mapped into it is shown whole by one view. Five tests reserved
exactly as many pages as they allocated, took that path, and then found
an unmapped page still committed (MEM_COMMIT 0x1000 where MEM_RESERVE
0x2000 was expected): issues #2 and #8.

- Those tests allocate one page more than their reservation, so they
  test the per-page path they were written for.
- a_reservation_is_shown_whole tests the whole path: one view over a
  reservation mapped in three calls, pages placed where the title first
  puts them, unmapping leaves the view, page-mapping copies refused.
- map_alias of no bytes returns true before looking for reservations
  shown whole: an empty range at the start of one counted as inside it,
  so mapping_no_pages_changes_nothing failed about 1 run in 20 when the
  new test's reservation followed its own.

cargo test -p victory-hle --lib xmem: 15 passed, 100 runs in a row
(main: 9 passed, 5 failed). Whole victory-hle lib: 103 passed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:33:10 +00:00
Author
Owner

@⁠Ekabusto on GitHub · 2026-11-25 12:47 UTC · original

For whoever reviews this: #14 fixes the same five failures and conflicts with this PR. It limits map_whole to reservations of 16 MiB and up, matching the GPU side's 16 MiB minimum for in-place mapped views, instead of changing the tests. I think #14 is the better fix for the title; if it is merged, I'll close this one.

AI-assisted (Claude Code).

**@⁠Ekabusto** on GitHub · 2026-11-25 12:47 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/16#issuecomment-7162862028) For whoever reviews this: #14 fixes the same five failures and conflicts with this PR. It limits `map_whole` to reservations of 16 MiB and up, matching the GPU side's 16 MiB minimum for in-place mapped views, instead of changing the tests. I think #14 is the better fix for the title; if it is merged, I'll close this one. AI-assisted (Claude Code).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/16/head:github-bot/gh-16'
git switch 'github-bot/gh-16'

Merge

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