XGameRuntime: validate XAsyncBlock before forwarding to system runtime (#1390) #1406

Open
github-bot wants to merge 2 commits from github-bot/gh-1406 into main AGit
Owner

@⁠hajduzsolt on GitHub · 2026-11-24 15:39 UTC · original
hajduzsolt:fix/xasync-null-block-forwarding → main · +106 −13 · 1 files · 2 commits · open

Runtime fix verified with unit tests and RX 9070 XT smoke run.

What is in it

  • crates/xcl/src/hle/xgameruntime/xasync.rs:
  • XAsyncBegin: validate async_block.is_null() || provider == 0 before forwarding to pc(0).
  • XAsyncBeginAlloc: validate async_block.is_null() || provider == 0 before forwarding to pc(1).
  • XAsyncBeginAllocWithCustomSize: validate async_block.is_null() || provider == 0 before forwarding to pc(2).
  • XAsyncGetResult: validate async_block.is_null() before forwarding to pc(3).
  • XAsyncGetStatus: validate async_block.is_null() before forwarding to pc(4).
  • XAsyncCancel: validate async_block.is_null() before forwarding to pc(5).
  • XAsyncRun: validate async_block.is_null() || work == 0 before forwarding to pc(6).
  • XAsyncComplete: validate async_block.is_null() before executing completion.
  • Unit tests:
  • xasync_entry_points_reject_null_block: validates that all 8 entry points reject null blocks (and 0 provider/work) and return E_INVALIDARG (or return early for Complete/Cancel) in standalone mode.
  • xasync_entry_points_validate_before_pc_forwarding: installs a mock COM vtable with panic handlers via use_pc, verifying that none of the 8 entry points forward null blocks to the PC runtime.

Tested

  • Hardware: AMD Radeon RX 9070 XT 16GB, AMD Ryzen 7 9800X3D, Windows 11 x64, rustc 1.98.1 (48a229cea 2026-09-01), debug
  • cargo test --workspace -- --test-threads=4: 748 passed, 0 failed, 37 ignored (SKIPPED GPU tests: none)
  • cargo test -p xcl --lib hle::xgameruntime::xasync: 16 passed, 0 failed

Regression run

main:

xcl-smoke v1
commit: 082944135cd2b96288470a595861fa608eee08dc
gpu: AMD Radeon RX 9070 XT
title: b0ea61d5
seconds: 60
exit: 0x0
frames shown: 1678 (PresentX 1678)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13681 MB

PR:

xcl-smoke v1
commit: f69a5bbcd20b0145724822ea8e82de77acb228c6
gpu: AMD Radeon RX 9070 XT
title: b0ea61d5
seconds: 60
exit: 0x0
frames shown: 1677 (PresentX 1677)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14548 MB

Not tested

  • Physical execution against Microsoft Gaming Services on an Xbox-authenticated console account (verified via mock COM vtable and local xasync state machine).

AI use

  • Antigravity (Gemini 4 Hydrogen, low) wrote the code and unit tests, and drafted this description.
**@⁠hajduzsolt** on GitHub · 2026-11-24 15:39 UTC · [original](https://github.com/xcl-dev/xcl/pull/1406) `hajduzsolt:fix/xasync-null-block-forwarding` → `main` · +106 −13 · 1 files · 2 commits · open Runtime fix verified with unit tests and RX 9070 XT smoke run. **What is in it** - crates/xcl/src/hle/xgameruntime/xasync.rs: - XAsyncBegin: validate async_block.is_null() || provider == 0 before forwarding to pc(0). - XAsyncBeginAlloc: validate async_block.is_null() || provider == 0 before forwarding to pc(1). - XAsyncBeginAllocWithCustomSize: validate async_block.is_null() || provider == 0 before forwarding to pc(2). - XAsyncGetResult: validate async_block.is_null() before forwarding to pc(3). - XAsyncGetStatus: validate async_block.is_null() before forwarding to pc(4). - XAsyncCancel: validate async_block.is_null() before forwarding to pc(5). - XAsyncRun: validate async_block.is_null() || work == 0 before forwarding to pc(6). - XAsyncComplete: validate async_block.is_null() before executing completion. - Unit tests: - xasync_entry_points_reject_null_block: validates that all 8 entry points reject null blocks (and 0 provider/work) and return E_INVALIDARG (or return early for Complete/Cancel) in standalone mode. - xasync_entry_points_validate_before_pc_forwarding: installs a mock COM vtable with panic handlers via use_pc, verifying that none of the 8 entry points forward null blocks to the PC runtime. **Tested** - Hardware: AMD Radeon RX 9070 XT 16GB, AMD Ryzen 7 9800X3D, Windows 11 x64, rustc 1.98.1 (48a229cea 2026-09-01), debug - `cargo test --workspace -- --test-threads=4`: 748 passed, 0 failed, 37 ignored (SKIPPED GPU tests: none) - `cargo test -p xcl --lib hle::xgameruntime::xasync`: 16 passed, 0 failed **Regression run** main: ``` xcl-smoke v1 commit: 082944135cd2b96288470a595861fa608eee08dc gpu: AMD Radeon RX 9070 XT title: b0ea61d5 seconds: 60 exit: 0x0 frames shown: 1678 (PresentX 1678) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 13681 MB ``` PR: ``` xcl-smoke v1 commit: f69a5bbcd20b0145724822ea8e82de77acb228c6 gpu: AMD Radeon RX 9070 XT title: b0ea61d5 seconds: 60 exit: 0x0 frames shown: 1677 (PresentX 1677) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14548 MB ``` **Not tested** - Physical execution against Microsoft Gaming Services on an Xbox-authenticated console account (verified via mock COM vtable and local xasync state machine). **AI use** - Antigravity (Gemini 4 Hydrogen, low) wrote the code and unit tests, and drafted this description.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:53:05 +00:00
Author
Owner

@⁠Anon64 on GitHub · 2026-11-24 15:54 UTC · original

Regression run for this PR: head 7a5b17d, based on main 930e8b4. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release, XCL_NETWORK=0, A pressed every 4 s from 20 s, scripts/smoke.ps1 on a retail title for 60 s.

main 930e8b4:

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1537 (PresentX 1537)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 92236 MB

this PR:

xcl-smoke v1
commit: 7a5b17d70e4d5749b758d08a86060a47e74b6935
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1487 (PresentX 1487)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 87477 MB

No device removals or crashes; 97 % of main's frames, 95 % of its peak commit.

Both runs' peak commit is high because of this machine's pipeline preload list at the time (the same on main), not this PR.

Not tested: the whole suite; whether the title reaches the changed code in these 60 s.

Written with Claude Code (Claude Opus 5.5) from runs on this machine.

**@⁠Anon64** on GitHub · 2026-11-24 15:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/1406#issuecomment-7136818321) Regression run for this PR: head `7a5b17d`, based on `main` `930e8b4`. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release, `XCL_NETWORK=0`, A pressed every 4 s from 20 s, `scripts/smoke.ps1` on a retail title for 60 s. main `930e8b4`: ``` xcl-smoke v1 commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56 gpu: NVIDIA GeForce RTX 3060 title: retail-title seconds: 60 exit: 0x0 frames shown: 1537 (PresentX 1537) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 92236 MB ``` this PR: ``` xcl-smoke v1 commit: 7a5b17d70e4d5749b758d08a86060a47e74b6935 gpu: NVIDIA GeForce RTX 3060 title: retail-title seconds: 60 exit: 0x0 frames shown: 1487 (PresentX 1487) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 87477 MB ``` No device removals or crashes; 97 % of main's frames, 95 % of its peak commit. Both runs' peak commit is high because of this machine's pipeline preload list at the time (the same on `main`), not this PR. **Not tested:** the whole suite; whether the title reaches the changed code in these 60 s. Written with Claude Code (Claude Opus 5.5) from runs on this machine.
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-24 15:56 UTC · original · edited 2026-11-24 16:03 UTC

Full-suite run, since this PR has no test report yet. Tested exact head 7a5b17d (on its base 930e8b4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 753 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: xasync_entry_points_reject_null_block, xasync_entry_points_validate_before_pc_forwarding.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 753 passed, 0 failed, 41 ignored, no skips.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-24 15:56 UTC · [original](https://github.com/xcl-dev/xcl/pull/1406#issuecomment-7136868561) · edited 2026-11-24 16:03 UTC Full-suite run, since this PR has no test report yet. Tested exact head `7a5b17d` (on its base `930e8b4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4`: **753 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - The new tests ran and passed: `xasync_entry_points_reject_null_block`, `xasync_entry_points_validate_before_pc_forwarding`. - Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **753 passed, 0 failed, 41 ignored**, no skips. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 17:08 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 17:08 UTC · [original](https://github.com/xcl-dev/xcl/pull/1406#issuecomment-7138746352) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. Thanks!
Author
Owner

@⁠hajduzsolt on GitHub · 2026-11-25 14:59 UTC · original

To preserve the useful review coverage from #1588, commit dbe475c gives each mock PC forwarding slot its exact function signature and checks both that invalid calls never reach the host and that a valid status call does.

  • cargo test -p xcl --lib xasync_entry_points_validate_before_pc_forwarding -- --test-threads=2: 1 passed, 0 failed, 0 ignored.
  • cargo test --workspace -- --test-threads=2: passed with 0 failures; xcl unit tests: 709 passed, 21 ignored. Other workspace and documentation tests passed.

The new head is queued for automated RX 9070 XT smoke verification.

**@⁠hajduzsolt** on GitHub · 2026-11-25 14:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/1406#issuecomment-7166119311) To preserve the useful review coverage from #1588, commit `dbe475c` gives each mock PC forwarding slot its exact function signature and checks both that invalid calls never reach the host and that a valid status call does. - `cargo test -p xcl --lib xasync_entry_points_validate_before_pc_forwarding -- --test-threads=2`: 1 passed, 0 failed, 0 ignored. - `cargo test --workspace -- --test-threads=2`: passed with 0 failures; xcl unit tests: 709 passed, 21 ignored. Other workspace and documentation tests passed. The new head is queued for automated RX 9070 XT smoke verification.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 05:13 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 05:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/1406#issuecomment-7183286249) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
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/1406/head:github-bot/gh-1406'
git switch 'github-bot/gh-1406'

Merge

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