Skip to content

Tests: tell a leaked XApu buffer from another allocation at its address - #2700

Open
sage-sage wants to merge 1 commit into
xcl-dev:mainfrom
sage-sage:tests/xapu-connect-release-check
Open

sage-sage wants to merge 1 commit into
xcl-dev:mainfrom
sage-sage:tests/xapu-connect-release-check

Conversation

@sage-sage

@sage-sage sage-sage commented Nov 26, 2026 •

Copy link
Copy Markdown

hle::acphal::tests::xapu_connect_returns_oom_and_cleans_up_on_failure is flaky in parallel runs: it checks that the data buffer was released by asking VirtualQuery whether its address is free, and another test's thread can get an allocation at that address between the release and the check (left: 4096, right: 65536, a 4 KiB committed region where the 64 KiB buffer was). Test-only change.

What is in it

  • crates/xcl/src/hle/acphal.rs: the test's allocator reserves 0x53000 bytes (a size nothing else in the process allocates) and commits the buffer at its start (a failed commit releases the reservation); the check fails only if an allocation of exactly that size still starts at the buffer's address. Another allocation there, or none, passes.

Tested

Regression run

  • None needed: test-only change (only the #[cfg(test)] test in acphal.rs changes).

Not tested

  • Nothing outside the test changes; AMD / Intel.

AI use

  • Claude Code, Claude Opus 5.5: found the flake in repeated parallel runs, wrote the change, ran the tests and wrote this description.

🤖 Generated with Claude Code

@luckyteagirl luckyteagirl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

At head b4ea470062ddef4c949c044524b68b556eca3750, the new test allocator reserves RESERVED bytes and then commits sz (acphal.rs:1299-1303). If the reserve succeeds but the commit returns null, then_some(p) discards the only base pointer and returns None; the 0x53000-byte reservation remains until the test process exits. This is particularly possible under the commit pressure where this OOM fixture runs. Could the failed-commit branch call VirtualFree(p, 0, MEM_RELEASE) before returning None? Microsoft's VirtualFree contract specifies the reserved base and zero size for MEM_RELEASE.

This is a source-derived test-only review of the exact head; I did not inject a commit failure. AI use: OpenAI Codex (GPT-6.2 Sol) identified the partial-allocation path, and I checked the diff and Win32 contract before posting.

`xapu_connect_returns_oom_and_cleans_up_on_failure` checked that the
data buffer was released by asking VirtualQuery whether its address is
free. In a parallel run another test's thread can get an allocation at
that address between the release and the check, and the test failed
(`left: 4096, right: 65536`): 7 of about 200 runs of the `hle::` tests
at `--test-threads=12` on an RTX 4080 SUPER machine.

The test's allocator now reserves 0x53000 bytes, a size nothing else in
the process allocates, and the check fails only if an allocation of
exactly that size still starts at the buffer's address.

Assisted-by: Claude Code (Claude Opus 5.5)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sage-sage
sage-sage force-pushed the tests/xapu-connect-release-check branch from b4ea470 to c8a7d45 Compare November 26, 2026 08:55
@sage-sage

Copy link
Copy Markdown
Author

@luckyteagirl thank you, fixed in c8a7d45 (squashed): when the commit fails, the test allocator now releases the reservation (VirtualFree(p, 0, MEM_RELEASE)) before returning None. cargo test --workspace -- --test-threads=4 on c8a7d45: 1435 passed, 0 failed, 47 ignored (RTX 4080 SUPER, debug); I did not inject a commit failure either.

Claude Code (Claude Opus 5.5) made the change, ran the tests and wrote this reply.

@rgroenewoudt

Copy link
Copy Markdown

Tested on AMD Radeon RX 9070 (RDNA4) at this PR's head c8a7d45: xapu_connect_returns_oom_and_cleans_up_on_failure passed in all 20 parallel runs.

Tested

Not tested

  • main without this change at --test-threads=12 on this card, so I have no failure rate from before

AI use

  • Claude Code (Claude Opus 5.5) ran the commands and wrote this report from the logs.

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