inplace test: decommit the pages again for up to two seconds (the test failed about 8 runs in 100) #878

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

@⁠MamaLeVrai on GitHub · 2026-11-25 11:34 UTC · original
MamaLeVrai:inplace-test-decommit → main · +13 −1 · 1 files · 1 commits · open

inplace::tests::warp_a_title_buffer_in_place_shows_its_bytes_at_its_offset fails now and then in the whole victory-gpu test binary on main (f85101b), and never alone. On this machine (Windows 11, RX 6950 XT, Rust 1.98.1): 10 failures in 120 runs of the binary (the test alone: 0 in 100 runs). eazyves saw the same test fail 4 in 100 runs on an RX 9070 XT in #849.

Which assertion. I printed the Windows error in the failing runs. The failing line is inplace.rs:1239, assert_ne!(mem::VirtualFree(base.add(2 * K64).cast(), K64, mem::MEM_DECOMMIT), 0), and the error is ERROR_INVALID_PARAMETER (87). That line runs right after drop(placed).

Why, as far as I can tell. I did not read the host's code; this is inferred from the behaviour: the placed buffer is a view of the test's own memory made through the device, and dropping it hands the pages back to the runtime, which lets go of them a moment later. While other tests of the binary keep the (WARP) device busy, the decommit can come before that, and it fails.

The change. The test repeats the decommit every 10 ms for up to 2 seconds and asserts it in the end, with the Windows error in the message. Only the test changes.

Checks. 250 runs of the whole victory-gpu test binary with this change: the test failed 0 times (before: 10 in 120). I did not run the other crates' tests again; nothing outside this test changes. The binary still fails for the reasons #849 fixes (the indirect budget test) and for the rare crash in #850; those are not in this PR.

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

🤖 Generated with Claude Code

**@⁠MamaLeVrai** on GitHub · 2026-11-25 11:34 UTC · [original](https://github.com/fxceless/victory-fork/pull/878) `MamaLeVrai:inplace-test-decommit` → `main` · +13 −1 · 1 files · 1 commits · open `inplace::tests::warp_a_title_buffer_in_place_shows_its_bytes_at_its_offset` fails now and then in the whole `victory-gpu` test binary on `main` (`f85101b`), and never alone. On this machine (Windows 11, RX 6950 XT, Rust 1.98.1): 10 failures in 120 runs of the binary (the test alone: 0 in 100 runs). `eazyves` saw the same test fail 4 in 100 runs on an RX 9070 XT in #849. **Which assertion.** I printed the Windows error in the failing runs. The failing line is `inplace.rs:1239`, `assert_ne!(mem::VirtualFree(base.add(2 * K64).cast(), K64, mem::MEM_DECOMMIT), 0)`, and the error is `ERROR_INVALID_PARAMETER` (87). That line runs right after `drop(placed)`. **Why, as far as I can tell.** I did not read the host's code; this is inferred from the behaviour: the placed buffer is a view of the test's own memory made through the device, and dropping it hands the pages back to the runtime, which lets go of them a moment later. While other tests of the binary keep the (WARP) device busy, the decommit can come before that, and it fails. **The change.** The test repeats the decommit every 10 ms for up to 2 seconds and asserts it in the end, with the Windows error in the message. Only the test changes. **Checks.** 250 runs of the whole `victory-gpu` test binary with this change: the test failed 0 times (before: 10 in 120). I did not run the other crates' tests again; nothing outside this test changes. The binary still fails for the reasons #849 fixes (the indirect budget test) and for the rare crash in #850; those are not in this PR. AI-assisted (Claude Code); no game data. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
warp_a_title_buffer_in_place_shows_its_bytes_at_its_offset drops its placed buffer and then
decommits part of the memory under it. The host lets go of those pages a moment after the drop,
and while other tests keep the device busy VirtualFree(MEM_DECOMMIT) failed with
ERROR_INVALID_PARAMETER in about 8 runs in 100 of the whole test binary (0 in 100 alone).

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

@⁠HailLucifer666 on GitHub · 2026-11-25 15:20 UTC · original

Independent confirmation of your diagnosis, from a different angle, and one negative result that may save someone an hour.

I hit the same failure today on my own machine (Windows 10, software adapter) while checking a branch under four concurrent test processes rather than one binary's threads:

configuration failures
test alone, 40 runs 0
whole binary, 32 runs, four-way process load 3 of 29 usable (3 of 32 runs crashed)
...with an extra fence-wait before the decommit 4 of 32
...with a bounded retry on the decommit itself 0 of 32

Same assertion, same silence: left: 0 right: 0.

The negative result. The obvious fix is to submit one empty command list after drop(placed) and wait for its fence, on the theory that the runtime frees the heap when the queue finishes. It does not: 4 failures in 32, against 3 in 29 without. The release is not tied to our submissions, so waiting for a fence buys nothing. Only waiting on the VirtualFree outcome worked.

The mechanism, for whoever reads this next. drop(placed) drops the last reference; D3D12 releases the heap asynchronously, and until it does the pages stay closed to everyone — VirtualFree there answers error 87, which is exactly what inplace.rs's module header says a title sees while a heap from its address stands. So this is the header's rule observed from the other side, not a test artefact.

One suggestion for the message, since left: 0 right: 0 is what made this expensive to read:

assert_ne!(
    freed, 0,
    "decommit still refused after {waits} ms: {refused}      (87 means a heap from this address is still standing)"
);

capturing std::io::Error::last_os_error() on each attempt. It turns the failure into a sentence that names the cause.

Your two seconds and my one second are the same fix — I am not opening a competing PR; I've dropped my branch. Yours is the one to take. The only thing I'd add is the error text.

**@⁠HailLucifer666** on GitHub · 2026-11-25 15:20 UTC · [original](https://github.com/fxceless/victory-fork/pull/878#issuecomment-7166688606) Independent confirmation of your diagnosis, from a different angle, and one negative result that may save someone an hour. I hit the same failure today on my own machine (Windows 10, software adapter) while checking a branch under **four concurrent test processes** rather than one binary's threads: | configuration | failures | |---|---| | test alone, 40 runs | 0 | | whole binary, 32 runs, four-way process load | 3 of 29 usable (3 of 32 runs crashed) | | ...with an extra fence-wait before the decommit | 4 of 32 | | ...with a bounded retry on the decommit itself | 0 of 32 | Same assertion, same silence: `left: 0 right: 0`. **The negative result.** The obvious fix is to submit one empty command list after `drop(placed)` and wait for its fence, on the theory that the runtime frees the heap when the queue finishes. It does not: 4 failures in 32, against 3 in 29 without. The release is not tied to our submissions, so waiting for a fence buys nothing. Only waiting on the `VirtualFree` outcome worked. **The mechanism, for whoever reads this next.** `drop(placed)` drops the last reference; D3D12 releases the heap asynchronously, and until it does the pages stay closed to everyone — `VirtualFree` there answers **error 87**, which is exactly what `inplace.rs`'s module header says a *title* sees while a heap from its address stands. So this is the header's rule observed from the other side, not a test artefact. **One suggestion for the message**, since `left: 0 right: 0` is what made this expensive to read: ```rust assert_ne!( freed, 0, "decommit still refused after {waits} ms: {refused} (87 means a heap from this address is still standing)" ); ``` capturing `std::io::Error::last_os_error()` on each attempt. It turns the failure into a sentence that names the cause. Your two seconds and my one second are the same fix — I am **not** opening a competing PR; I've dropped my branch. Yours is the one to take. The only thing I'd add is the error text.
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/878/head:github-bot/gh-878'
git switch 'github-bot/gh-878'

Merge

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