XGameRuntime: validate XAsyncBlock before PC runtime forwarding (#1390) #1578
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1588"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by hajduzsolt on 2026-11-24T17:59:52Z.
Validates null XAsyncBlock, missing provider/work pointers, and E_PENDING before forwarding XAsync* entry points through pc(slot) to system xgameruntime.dll. Fixes #1390.
What is in it
Tested
Regression run
main:
PR:
Not tested
AI use
Imported from ivall/xcl. Originally posted by gut0to on 2026-11-24T18:04:47Z.
Review: COMMENTED
AI-assisted review (GPT-6): I traced the valid forwarding call and the function pointer type used for slot 3.
Imported from ivall/xcl. Originally posted by pickles976 on 2026-11-24T18:05:36Z.
Verdict: correct and well-scoped — the invariant "never forward null into a host binary that will not check" is exactly right, and failing with
E_INVALIDARGat our boundary is doubly right when the host would have AV-ed inside a Microsoft DLL (whose stack the user then pastes, sending the hunt to Redmond). This is the same family as my #836 (loader write-site hardening) moved to the HLE-forwarding edge: four sibling projects keep finding that manual forwarding layers validate at the wrong time — and the completion that stops the next five issues of this family is mechanical: enumerate every remainingpc(slot)forwarding entry point once and classify each as check-optional (host documents its own validation) vs check-required, with the list living as a table in the forwarding module so future HLE additions answer the question at the review stage. Happy to cross-check the resulting list against the sibling runtime's equivalent surface (we forward to the real d3d12/xgameruntime too) — two runtimes running the same enumeration is how #836's class finally stopped producing incidents: the parse-time invariant, once adopted, ate five bugs at once.Imported from ivall/xcl. Originally posted by gut0to on 2026-11-24T18:04:47Z.
Code review location:
crates/xcl/src/hle/xgameruntime/xasync.rs; line 1265Slot 3 is used by
XAsyncGetStatus, which calls it through the three-argument typefn(usize, *mut XAsyncBlock, bool) -> HRESULT.trap_hrabove has sixusizeparameters, so invoking this pointer with that incompatible Rust function signature is undefined behavior even if the Windows x64 ABI happens to tolerate extra arguments. Please give slot 3 a stub with the exactXAsyncGetStatussignature. AI-assisted review: I verified the call site and function pointer type.Imported from ivall/xcl. Originally posted by hajduzsolt on 2026-11-24T19:06:20Z.
Thanks for catching the ABI mismatch. The slot 3 mock now has the exact XAsyncGetStatus signature.
cargo test --workspace -- --test-threads=2passed (with the existing ignored tests).Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T20:02:58Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T05:14:52Z.
Empirical test report (
66f0068b)Hardware / environment
rustc --versionreturnedrustc 1.100.0 (0ef1bc386 2026-11-09).dxc.exe --versionreturneddxcompiler.dll: 1.9(5512-01b62ad4)(1.9.2609.5) - 1.9.2609.5 (01b62ad47).66f0068bc0ea263afa2c1cb7c5ceabf9e7263dde.Commands and results
cargo test --workspace --no-runcompleted with exit code 0 and built 19 test executables. It executed zero tests.XCL_ADAPTER=NONE_CPU_ONLYandRUST_TEST_NOCAPTURE=1,cargo test -p xcl --lib hle::xgameruntime::xasync::tests::pc_forwarding_validates_null_and_args_before_dispatching -- --exact --nocapturecompleted with exit code 0. The log recorded 1 passed, 0 failed, 0 ignored, 0 skipped, and 831 filtered out.Atomic*::fetch_update. Neither command usedInvoke-ArcTest.ps1or held the Arc GPU mutex.Observed behavior
The regression test uses an in-process mock PC runtime vtable. Null async blocks, a zero provider in
XAsyncBegin, a zero work callback inXAsyncRun, andE_PENDINGinXAsyncCompleteproduced zero mock calls. The HRESULT-returning invalid calls returnedE_INVALIDARG. A validXAsyncGetStatuscall reached the mock exactly once and returnedS_OK.Not tested
Coverage was limited to the focused CPU regression test and compilation of the workspace tests. The full GPU workspace suite and game smoke runs were omitted.
AI use
Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against
pr1588-focused.logand published.Imported from ivall/xcl. Originally posted by hajduzsolt on 2026-11-25T14:59:21Z.
Thank you for the ABI review and the forwarding audit suggestion. This PR duplicates the earlier #1406, which now includes exact-signature mocks and a valid-forwarding control in
dbe475c, so I am closing this copy. The broader inventory of other forwarding entry points remains a separate follow-up and has not been completed by this change.Pull request closed