XMem test: a freed watched reservation is proven released by taking its range, not by finding it free #4419

Closed
github-bot wants to merge 14 commits from github-bot/gh-4418 into main AGit
Owner

@⁠boraswim on GitHub · 2026-11-30 20:09 UTC · original
boraswim:fix/write-watch-test-free → main · +985 −849 · 32 files · 14 commits · closed without merging

Part of #2420 (item 2).

What it changes

modules::xmem::tests::large_default_allocations_honour_write_watch_switch fails in 1 to 2 runs in 10 of cargo test -p victory-hle --lib on Windows:

assertion `left == right` failed: field 0x0
  left: 8192     // MEM_RESERVE
 right: 65536    // MEM_FREE

After XMemFreeDefault the test checked that the reservation's base was MEM_FREE. Title memory is reserved through VirtualAlloc2 with an address requirement, so Windows hands out the lowest free range above 4 GiB, and a test on another thread can reserve the freed range before the check runs. A range found in use doesn't prove the free failed.

The test now proves the release by reserving the exact range itself (VirtualAlloc(base, reserved, MEM_RESERVE, PAGE_NOACCESS)). Nothing else can hold the range at that moment, and the test gives it back at once. If the range was taken in between, it allocates and frees again, up to 8 times. A free that doesn't release fails every attempt. Test-only.

How it was tested

  • GPU and profile: unit tests only (Windows 11, rustc 1.98.1, RTX 4070 SUPER)
  • Before: 1 to 2 failures of this test per 10 parallel runs of cargo test -p victory-hle --lib --locked
  • After: 0 failures in 12 runs, and 0 in 8 more after rebasing on e1251c31
  • Mutation check: with XMemFreeDefault changed to decommit instead of release, the test fails with the reservation was not released (0x2000). Reverted.
  • For shader changes, the wave sizes tested: not a shader change
  • cargo test passed for the crates it touches: this test, yes. In those runs a_read_by_range_waits_only_for_a_remapping_that_meets_it still fails, which #2439 fixes.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #2420 (the issue), #2439 (the other xmem test flake, separate test and lines). Open PRs touching xmem.rs (#2133, #2263, #2390) change runtime code, not this test.
**@⁠boraswim** on GitHub · 2026-11-30 20:09 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4418) `boraswim:fix/write-watch-test-free` → `main` · +985 −849 · 32 files · 14 commits · closed without merging Part of #2420 (item 2). ## What it changes `modules::xmem::tests::large_default_allocations_honour_write_watch_switch` fails in 1 to 2 runs in 10 of `cargo test -p victory-hle --lib` on Windows: ``` assertion `left == right` failed: field 0x0 left: 8192 // MEM_RESERVE right: 65536 // MEM_FREE ``` After `XMemFreeDefault` the test checked that the reservation's base was `MEM_FREE`. Title memory is reserved through `VirtualAlloc2` with an address requirement, so Windows hands out the lowest free range above 4 GiB, and a test on another thread can reserve the freed range before the check runs. A range found in use doesn't prove the free failed. The test now proves the release by reserving the exact range itself (`VirtualAlloc(base, reserved, MEM_RESERVE, PAGE_NOACCESS)`). Nothing else can hold the range at that moment, and the test gives it back at once. If the range was taken in between, it allocates and frees again, up to 8 times. A free that doesn't release fails every attempt. Test-only. ## How it was tested - GPU and profile: unit tests only (Windows 11, rustc 1.98.1, RTX 4070 SUPER) - Before: 1 to 2 failures of this test per 10 parallel runs of `cargo test -p victory-hle --lib --locked` - After: 0 failures in 12 runs, and 0 in 8 more after rebasing on e1251c31 - Mutation check: with `XMemFreeDefault` changed to decommit instead of release, the test fails with `the reservation was not released (0x2000)`. Reverted. - For shader changes, the wave sizes tested: not a shader change - `cargo test` passed for the crates it touches: this test, yes. In those runs `a_read_by_range_waits_only_for_a_remapping_that_meets_it` still fails, which #2439 fixes. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #2420 (the issue), #2439 (the other xmem test flake, separate test and lines). Open PRs touching `xmem.rs` (#2133, #2263, #2390) change runtime code, not this test.
large_default_allocations_honour_write_watch_switch checked that the
reservation's base was MEM_FREE right after XMemFreeDefault. Title memory
is handed out lowest first, so a test on another thread could reserve the
range in between and the check found MEM_RESERVE (1 to 2 runs in 10 of
`cargo test -p victory-hle --lib`). The test now reserves the exact range
itself (nothing else holds it then) and gives it back; when the range is
taken it allocates and frees again, up to 8 times. A free that does not
release fails every attempt (checked by making XMemFreeDefault decommit
instead: "the reservation was not released (0x2000)"). 0 failures in 12
parallel runs.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 20:13:20 +00:00
Author
Owner

@⁠boraswim on GitHub · 2026-11-30 20:13 UTC · original · edited 2026-11-30 20:52 UTC

The red check is main's clippy (loop_caps in lower.rs, Shadow::ranged, is_multiple_of in host.rs), the same three errors as main's run on e1251c31. #4297 (or #2048) fixes them. This PR only changes one test in xmem.rs.

**@⁠boraswim** on GitHub · 2026-11-30 20:13 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4418#issuecomment-7290593646) · edited 2026-11-30 20:52 UTC The red `check` is main's clippy (`loop_caps` in lower.rs, `Shadow::ranged`, `is_multiple_of` in host.rs), the same three errors as main's run on e1251c31. #4297 (or #2048) fixes them. This PR only changes one test in xmem.rs.
github-bot closed this pull request 2026-12-01 18:43:41 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:41 UTC · original

Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:41 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4418#issuecomment-7321363677) Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!4419
No description provided.