Skip to content

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

Open
MamaLeVrai wants to merge 1 commit into
fxceless:mainfrom
MamaLeVrai:inplace-test-decommit
Open

MamaLeVrai wants to merge 1 commit into
fxceless:mainfrom
MamaLeVrai:inplace-test-decommit

Conversation

@MamaLeVrai

Copy link
Copy Markdown

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

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 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 25, 2026 11:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants