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

Open
hajduzsolt wants to merge 2 commits from upstream-pr/1406 into main
hajduzsolt commented 2026-11-24 15:39:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by hajduzsolt on 2026-11-24T15:39:50Z.


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.
<!-- greyfinch-sync:ivall/xcl:issue:5475363121 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1406). Originally posted by [hajduzsolt](https://github.com/hajduzsolt) on 2026-11-24T15:39:50Z. --- 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.
Anon64 commented 2026-11-24 16:07:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Anon64 on 2026-11-24T15:54:43Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7136818321 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1406#issuecomment-7136818321). Originally posted by [Anon64](https://github.com/Anon64) on 2026-11-24T15:54:43Z. --- 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.
futurepro62 commented 2026-11-24 16:07:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T15:56:33Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7136868561 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1406#issuecomment-7136868561). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T15:56:33Z. --- 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.
DavidM1911 commented 2026-11-24 18:08:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T17:08:28Z.


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

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

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7138746352 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1406#issuecomment-7138746352). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T17:08:28Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. Thanks!
hajduzsolt commented 2026-11-25 15:08:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by hajduzsolt on 2026-11-25T14:59:02Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7166119311 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1406#issuecomment-7166119311). Originally posted by [hajduzsolt](https://github.com/hajduzsolt) on 2026-11-25T14:59:02Z. --- 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.
DavidM1911 commented 2026-11-26 06:06:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T05:13:05Z.


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

<!-- greyfinch-sync:ivall/xcl:comment:7183286249 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1406#issuecomment-7183286249). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T05:13:05Z. --- 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
github-actions[bot] commented 2026-12-01 02:32:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-12-01T02:32:12Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7298721731 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1406#issuecomment-7298721731). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-12-01T02:32:12Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 05:39:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:39:10Z.


Triage (#1607) – head f69a5bb

#1588 made the same change (null / argument checks moved before the pc() forwarding in xasync.rs) and is closed; nothing equivalent is on main yet.
No problems found in the diff: returning early on XAsyncComplete(E_PENDING) before forwarding matches the system runtime's own no-op for E_PENDING, and the second test checks that no forwarded slot is hit for null blocks.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7301994871 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1406#issuecomment-7301994871). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:39:10Z. --- **Triage (#1607)** – head f69a5bb #1588 made the same change (null / argument checks moved before the pc() forwarding in xasync.rs) and is closed; nothing equivalent is on main yet. No problems found in the diff: returning early on XAsyncComplete(E_PENDING) before forwarding matches the system runtime's own no-op for E_PENDING, and the second test checks that no forwarded slot is hit for null blocks. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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/1406:upstream-pr/1406'
git switch 'upstream-pr/1406'

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/1406'
git switch 'upstream-pr/1406'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1406'
git switch 'upstream-pr/1406'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1406'
git switch 'main'
git merge --squash 'upstream-pr/1406'
git switch 'main'
git merge --ff-only 'upstream-pr/1406'
git switch 'main'
git merge 'upstream-pr/1406'
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
xcl-dev/xcl!1396
No description provided.