XGameRuntime: fix IUnknown/sibling QI and forwarding alias isolation #1610
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!1610
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1610"
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?
@b3IKK on GitHub · 2026-11-24 18:14 UTC · original
b3IKK:xgameruntime/api-qi-forward-and-mount-leak→main· +74 −2 · 1 files · 1 commits · openAddresses
XCL-BT-040from #1488. Two bugs incrates/xcl/src/hle/xgameruntime/api.rs:query_interface()refusedIID_IUnknownon fallback objects (xcl_xasync_object,xcl_xaccessibility_object) and on non-main interface objects (XPACKAGE_V1_IID, …), and refused cross-interfaceQueryInterfaceto a sibling interface of the same COM class (e.g.XUSER→XUSER_GAMERTAG_IID).QueryApiImplsharedo.pcon forwarding classes (XGAMEUI) wheniid == clsideven thoughclsidis not ino.iface.iids, letting a shorter host vtable poisono.pcfor the higher forwarded slots.This returns the canonical identity object for
IID_IUnknown(the class'smainobject, orthisfor standalone fallback objects), answers cross-interfaceQueryInterfacefor known sibling interfaces, and isolates a forwarding class's alias unless the IID asked is its single table IID.Since the first version (#1607, group D68): the
mount_with_ui_asyncchange is gone. It mounted before the async work and so leaked on a terminated queue; #1242 mounts inside the work closure and covers that with a test, so this PR no longer competes with it.On group D47 (#1593, #1615, and this PR): all three make
QueryInterface(IUnknown)succeed. #1593 came first and is that change alone; what is left here is the sibling-interface lookup and the forwarding alias rule, neither of which the other two have. If #1593 merges first this one needs a small rebase in the same function.What is in it
crates/xcl/src/hle/xgameruntime/api.rs:query_interfaceanswersIID_IUnknownwith the class's main object and looks up sibling interfaces;QueryApiImplisolates a forwarding class's alias unless the IID is its single table IID. Testsquery_interface_accepts_iunknown_and_sibling_interfacesandquery_api_impl_isolates_forwarding_alias.Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 995 passed, 0 failed, 45 ignored (SKIPPED: the wave64 / direct-DXIL per-lane tests that need 64-lane hardware or a semantics mode this adapter refuses,no heap windows, andcannot disable the driver cache (Windows Developer Mode is required))cargo test -p xcl --lib -- hle::xgameruntime::api: 19 passed, 0 failed. Both new tests put on top ofmain'sapi.rs: 0 passed, 2 failed —IUnknown QI must succeed on xcl_xasync_object(E_NOINTERFACE) andXGAMEUI with iid == clsid must use an isolated forward alias(same pointer twice).Regression run
main (
80f4819, clean tree, no local changes):PR (
d3e2053, clean tree, no local changes):Not tested
IID_IUnknownor a sibling interface on these objects (the tests build the calls)AI use
xgameruntime/api.rs, wrote the fixes and both tests (and confirmed they fail onmain's code), took the mount change out in favour of #1242, rebased onto80f4819, ran the test suite and thescripts/smoke.ps1runs, and drafted this PR description.@b3IKK on GitHub · 2026-11-24 18:33 UTC · original
Good catch @gut0to — updated in \4ddfd00\ so \QueryInterface(IID_IUnknown)\ always returns the canonical \main\ object for \.clsid\ (falling back to \ his\ for standalone fallback objects like \xcl_xasync_object), and updated \query_interface_accepts_iunknown_and_sibling_interfaces\ to assert COM identity across both \XPackage/\XPackage v1\ and \XUser/\XUser gamertag. Re-ran \scripts/test.ps1\ and the 60 s \scripts/smoke.ps1\ run.
@futurepro62 on GitHub · 2026-11-24 18:56 UTC · original
Full-suite run, since this PR has no test report yet. Tested exact head
4ddfd00(on its base9e3831e).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form: 777 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.query_interface_accepts_iunknown_and_sibling_interfaces,query_api_impl_isolates_forwarding_alias_and_mount_validates_block.f045aa7(the PR was updated before the NVIDIA run above) on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2,XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 778 passed, 0 failed, 41 ignored. SKIPPED:heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).heap_window_out_of_memory_falls_back_to_the_switch_formwas skipped with--skip. It fails on main9e3831etoo, not because of this PR: underXCL_REQUIRE_GPU=mesh,runner::skip_testturns every skip except "no wave64" into a failure, including this test's opt-in "no heap windows" skip (XCL_HEAP_WINDOWSunset). Reported as #1651.Not tested
AI use
@DavidM1911 on GitHub · 2026-11-24 20:30 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.Thanks!
@b3IKK on GitHub · 2026-11-25 00:14 UTC · original
Rebased onto
80f4819and reduced: themount_with_ui_asyncchange is out of this PR, since #1242 mounts inside the async work and covers the terminated-queue leak with a test (#1607, group D68). What is left is theQueryInterface(IUnknown)identity, the sibling-interface lookup and the forwarding alias rule; both tests fail onmain'sapi.rsand pass here. Suite 995 passed, 0 failed, 45 ignored. The old smoke blocks were from before the split, so the two in the description are new:80f4819(main) andd3e2053. AI use: OpenCode, Claude Fable 5.2.@JJAutoCompare on GitHub · 2026-11-25 05:08 UTC · original
PR #1610 focused Windows verification
Verified
d3e205313d8211881218b265d5b0489c3b5d3986on a clean detached checkout. The diff is confined tocrates/xcl/src/hle/xgameruntime/api.rs.Tested
0ef1bc386,x86_64-pc-windows-msvc). Unoptimized dev/test profiles with debuginfo and incremental compilation disabled.cargo build --workspaceandcargo test --workspace --no-runboth exited 0. The latter compiled the workspace test executables.cargo test -p xcl --lib xgameruntime -- --nocapturewithXCL_ADAPTER=NONE_CPU_ONLYexited 0.pr1610-focused.logreports 76 passed, 0 failed, 0 ignored, 895 filtered out, and 0 lines beginning withSKIPPED. Two existing tests returned early for missingSystem32\xgameruntime.dlland a missing default audio endpoint. The harness includes those in the passed count.query_interface_accepts_iunknown_and_sibling_interfacesverified that XAsync fallback returns its ownIUnknownpointer, XPackage v1 and main share the mainIUnknownpointer, and XUser can query its gamertag sibling with sharedIUnknownidentity.query_api_impl_isolates_forwarding_aliasverified that XGameUI queries by class ID and exact interface IID both succeed and return distinct XCL objects.Not tested
Only the focused XGameRuntime unit tests ran, alongside full workspace compilation. The full GPU workspace suite and retail-title smoke runs were omitted. Host XGameUI forwarding through Gaming Services was untested.
AI use
T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against
pr1610-focused.logand published.@ -377,1 +390,4 @@return S_OK;}if *iid == f.clsid || f.iids.contains(&*iid) {*out = this as *mut c_void;@gut0to on GitHub · 2026-11-24 18:19 UTC · original
For
IID_IUnknown, this returns the current per-interfaceObj. Sinceown()creates separate objects forXPACKAGEandXPACKAGE_V1_IID, querying IUnknown through those interfaces can return different pointers for the same COM object; the new test currently asserts that behavior. COM requires every interface on one object to return the same physical IUnknown pointer. Please return a canonical identity object for the class (including fallback objects) from every interface. AI-assisted review; I verified the object layout and the COM rule.github-bot referenced this pull request2026-11-26 06:18:30 +00:00
@DavidM1911 on GitHub · 2026-11-26 05:48 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
@gut0to on GitHub · 2026-11-24 18:19 UTC · original · reviewed
AI-assisted review; I checked the COM identity rule against Microsoft documentation.
@luckyteagirl on GitHub · 2026-11-25 22:40 UTC · original · reviewed
I see a sibling-
QueryInterfacealias escape in this head.QueryApiImplroutes non-table forwarding IIDs throughforward_alias_obj, but the sibling-QI branch below returnsown(&f.clsid, iid)directly. For a multi-IID forwarding class, that can return the merged baseObjeven though the per-IID alias owns the PC pointer.forward()then seespc == 0on the base and falls back tounknown_slot.Could sibling forwarding QI use the per-IID alias lookup too? A deterministic regression could QI from one
XGameUiforwarding alias to a second known IID, then verify the returned object is the second IID's alias (and, if feasible without a PC runtime, verify itspcinitialization path). I confirmed this from PR headd3e205313d8211881218b265d5b0489c3b5d3986; I did not execute a test locally. Codex (GPT-6) assisted with this code review.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.