XGameRuntime: validate XAsyncBlock before PC runtime forwarding (#1390) #1588
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1588
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1588/head"
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?
@hajduzsolt on GitHub · 2026-11-24 17:59 UTC · original
hajduzsolt:xgameruntime/xasync-validate-before-pc-forward→main· +86 −13 · 1 files · 2 commits · closed without mergingValidates 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
github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@pickles976 on GitHub · 2026-11-24 18:05 UTC · original
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.@hajduzsolt on GitHub · 2026-11-24 19:06 UTC · original
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).@DavidM1911 on GitHub · 2026-11-24 20:02 UTC · original
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!
@JJAutoCompare on GitHub · 2026-11-25 05:14 UTC · original
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.@hajduzsolt on GitHub · 2026-11-25 14:59 UTC · original
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.@ -1230,0 +1267,4 @@let mut vtable = [0usize; 12];vtable[3] = trap_status as *const () as usize;for s in [4usize, 6, 7, 9, 11] {vtable[s] = trap_hr as *const () as usize;@gut0to on GitHub · 2026-11-24 18:04 UTC · original
Slot 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.Pull request closed