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

Open
MamaLeVrai wants to merge 1 commit from upstream-pr/878 into main
MamaLeVrai commented 2026-11-25 11:34:32 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by MamaLeVrai on 2026-11-25T11:34:32Z.


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

<!-- greyfinch-sync:fxceless/victory-fork:issue:6603558218 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/878). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-25T11:34:32Z. --- `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)
copilot-pull-request-reviewer[bot commented 2026-11-25 12:06:57 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T11:34:47Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:fxceless/victory-fork:review:6056867354 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/878#pullrequestreview-6056867354). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/copilot-pull-request-reviewer%5Bbot%5D) on 2026-11-25T11:34:47Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
HailLucifer666 commented 2026-11-25 16:12:51 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by HailLucifer666 on 2026-11-25T15:20:28Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7166688606 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/878#issuecomment-7166688606). Originally posted by [HailLucifer666](https://github.com/HailLucifer666) on 2026-11-25T15:20:28Z. --- 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 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/878:upstream-pr/878'
git switch 'upstream-pr/878'

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