Media test: the file-creation callback outlives the test (victory-hle test process crash) #4732

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

@⁠KruIN689 on GitHub · 2026-12-01 04:11 UTC · original
KruIN689:up/media-callback-outlives → main · +9 −7 · 1 files · 1 commits · open

[pr-tests]

What it changes

modules::media::tests::asynchronous_file_creation_reads_the_rewritten_path hands MFBeginCreateFile a COM callback with no-op AddRef/Release, and both the object and its vtable sit on the test's stack. Media Foundation releases the callback on its work queue after Invoke returns. By then the test may be over and its thread's stack gone. That Release reads freed memory, and the whole victory-hle test process dies with 0xC0000005 (once 0xC0000409). It happens now and then on a busy or small machine, such as the 2-core CI runners.

The callback and its vtable are now leaked with Box::leak, so a late Release finds them. Only the test changes.

The other cause of the same process crash is in xasync::complete_call, which upstream #2927 fixes. That PR is open and needs a rebase.

How it was tested

  • GPU and profile: N/A (CPU-only HLE test). Ryzen 9 9950X3D, Windows 11. The test binary was pinned to CPUs 0-1, which is the only way it reproduces on a 32-thread PC.
  • Before (palmlight main, same test code): modules::media:: group, 2×10 runs in turns: 7 of 20 crashed. The test alone: 1 of 12.
  • After: 0 of 20 on palmlight; on this branch (upstream main 5fabb46e + this) 0 of 15, and 10 passed unpinned.
  • Whole victory-hle suite, pinned, 3×10 runs in turns, with #2927 applied too: 0 of 30 crashed, against 9 of 30 without both.
  • cargo test passed for the crates it touches: yes (cargo test -p victory-hle --lib).
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings: clean on palmlight. On upstream main it stops at victory-gpu's five existing errors (#4708), before reaching this crate.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #2927 (the xasync half of the same crash). No PR touches this test.

Same change in our fork: Lyrnc/palmlight#93.

Found and fixed with the help of Claude Code (Claude Opus 5.5).

**@⁠KruIN689** on GitHub · 2026-12-01 04:11 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4731) `KruIN689:up/media-callback-outlives` → `main` · +9 −7 · 1 files · 1 commits · open [pr-tests] ## What it changes `modules::media::tests::asynchronous_file_creation_reads_the_rewritten_path` hands `MFBeginCreateFile` a COM callback with no-op AddRef/Release, and both the object and its vtable sit on the test's stack. Media Foundation releases the callback on its work queue after `Invoke` returns. By then the test may be over and its thread's stack gone. That `Release` reads freed memory, and the whole `victory-hle` test process dies with 0xC0000005 (once 0xC0000409). It happens now and then on a busy or small machine, such as the 2-core CI runners. The callback and its vtable are now leaked with `Box::leak`, so a late `Release` finds them. Only the test changes. The other cause of the same process crash is in `xasync::complete_call`, which upstream #2927 fixes. That PR is open and needs a rebase. ## How it was tested - GPU and profile: N/A (CPU-only HLE test). Ryzen 9 9950X3D, Windows 11. The test binary was pinned to CPUs 0-1, which is the only way it reproduces on a 32-thread PC. - Before (palmlight main, same test code): `modules::media::` group, 2×10 runs in turns: 7 of 20 crashed. The test alone: 1 of 12. - After: 0 of 20 on palmlight; on this branch (upstream main 5fabb46e + this) 0 of 15, and 10 passed unpinned. - Whole `victory-hle` suite, pinned, 3×10 runs in turns, with #2927 applied too: 0 of 30 crashed, against 9 of 30 without both. - `cargo test` passed for the crates it touches: yes (`cargo test -p victory-hle --lib`). - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings`: clean on palmlight. On upstream main it stops at victory-gpu's five existing errors (#4708), before reaching this crate. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #2927 (the xasync half of the same crash). No PR touches this test. Same change in our fork: Lyrnc/palmlight#93. *Found and fixed with the help of Claude Code (Claude Opus 5.5).*
asynchronous_file_creation_reads_the_rewritten_path handed
MFBeginCreateFile a COM callback (and its vtable) on the test's stack,
with AddRef and Release that count nothing. Media Foundation releases
the callback on its work queue after Invoke returns; by then the test
may be over and its thread's stack gone, so that Release read freed
memory: the victory-hle test process died with 0xC0000005 (0xC0000409
once) on a busy or small machine. The callback and its vtable are now
leaked. Only the test changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 04:13:55 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-12-01 12:06 UTC · original · approved these changes

Reviewed crates/victory-hle/src/modules/media.rs: leaking the test's COM Callback and its vtable via Box::leak fixes the stack use-after-free when Media Foundation releases the callback on its async work queue after Invoke returns. Verified on Windows: cargo test -p victory-hle --lib modules::media::tests -- --test-threads=1 (10 passed, 0 failed).

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-12-01 12:06 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4731#pullrequestreview-6130937202) · **approved these changes** Reviewed crates/victory-hle/src/modules/media.rs: leaking the test's COM Callback and its vtable via Box::leak fixes the stack use-after-free when Media Foundation releases the callback on its async work queue after Invoke returns. Verified on Windows: cargo test -p victory-hle --lib modules::media::tests -- --test-threads=1 (10 passed, 0 failed). Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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/4732/head:github-bot/gh-4731'
git switch 'github-bot/gh-4731'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4731'
git switch 'github-bot/gh-4731'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4731'
git switch 'github-bot/gh-4731'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4731'
git switch 'main'
git merge --squash 'github-bot/gh-4731'
git switch 'main'
git merge --ff-only 'github-bot/gh-4731'
git switch 'main'
git merge 'github-bot/gh-4731'
git push origin 'main'
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!4732
No description provided.