XGameRuntime: fix IUnknown/sibling QI and forwarding alias isolation #1600
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T18:14:26Z.
Addresses
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.Imported from ivall/xcl. Originally posted by gut0to on 2026-11-24T18:19:27Z.
Review: COMMENTED
AI-assisted review; I checked the COM identity rule against Microsoft documentation.
Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T18:33:49Z.
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.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T18:56:33Z.
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
Imported from ivall/xcl. Originally posted by gut0to on 2026-11-24T18:19:27Z.
Code review location:
crates/xcl/src/hle/xgameruntime/api.rs; line 377For
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.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T20:30:18Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored.Thanks!
[PR #1610] XGameRuntime: fix IUnknown/sibling QI, forwarding alias isolation, and mount_with_ui_async leakto [PR #1610] XGameRuntime: fix IUnknown/sibling QI and forwarding alias isolationImported from ivall/xcl. Originally posted by b3IKK on 2026-11-25T00:14:55Z.
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.Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T05:08:57Z.
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.upstream-sync referenced this pull request2026-11-25 07:04:28 +00:00
Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-25T22:40:17Z.
Review: COMMENTED
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.Imported from ivall/xcl. Originally posted by CalvyPZ on 2026-11-25T22:41:37Z.
This PR has been marked as a duplicate and closed after multiple agreeing checks in #1607. If you believe this is incorrect please re-open with why.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T05:48:30Z.
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
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T16:08:28Z.
NVIDIA test report for
d3e2053: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug. Head tested as-is on its base80f4819.cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4: 937 passed, 0 failed, 25 ignored; 23 SKIPPED: 19no wave64, 3 lower_dxil per-lane f16 forms refused by design (#1426), 1 driver-cache test (Developer Mode off); none in api.rs.hle::xgameruntime::api::tests::query_interface_accepts_iunknown_and_sibling_interfacesandquery_api_impl_isolates_forwarding_alias, each with--exact --test-threads=1 --nocapture, 3 runs: 3/3 passed each, 0 SKIPPED. This does not cover the multi-IID forwarding sibling QI raised in review.Lib tests only; no title run.
AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T21:07:40Z.
merge-check claim
head:
d3e205313dImported from ivall/xcl. Originally posted by throny on 2026-11-28T21:36:55Z.
merge-check
base:
beeb81behead:
d3e205313dmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2596 passed, 0 failed, 49 ignored (27 SKIPPED lines). Base alone at
beeb81be(main after the merge of nvidia-dev): 2594 passed, 0 failed, 49 ignored.review: the identity rule itself is right (a query for IUnknown gives the same pointer from every sibling; the objects are static, so reference counts play no part). One point from the thread is unanswered and I can follow it in the code: for a forwarding class, the query path now gives every interface id except the one in the table its own alias and never fills the main object's forwarding target; a sibling query or a query for IUnknown then returns that main object, and calls forwarded through it return "not implemented" (no crash: the forward checks for the empty target). It also touches the same function as #1593 and #1615.
performance: none.
verdict: not yet: answer the forwarding-class case (fill the main object's target or return an alias there), and say how this relates to #1593 / #1615.
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by jsalzy on 2026-11-30T02:34:07Z.
merge-check claim
head:
d3e205313dImported from ivall/xcl. Originally posted by jsalzy on 2026-11-30T02:47:45Z.
merge-check
base:
9335bc0d86head:
d3e205313dmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2803 passed, 1 failed, 50 ignored; SKIPPED: 28 (22 no wave64 on this GPU; 3 per-lane form refused (#1426 semantics); 2 no heap windows (opt-in XCL_HEAP_WINDOWS=1); 1 driver cache cannot be disabled without Windows Developer Mode); failing: hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline (standin.rs:459, left (0, 1, 1), right (0, 0, 1)), fails on base too: main alone at
9335bc0gives 2801 passed, 1 failed (same test, same assertion), 50 ignored. The PR's two new tests (query_interface_accepts_iunknown_and_sibling_interfaces, query_api_impl_isolates_forwarding_alias) pass.review: the identity part is right: IUnknown answers with the class's main object from every sibling (the objects are static, so no reference counts are involved), and a sibling IID now finds its own object. The point from the first check is still open on current main, by reading the code (no test covers it): XGameUi has one table IID (eaf669df…), so QueryApiImpl(XGameUi, XGameUi) now hands out an alias, and a QueryInterface from that alias for IUnknown or for the table IID returns the shared main object, whose forward target is filled only if someone queried the exact table IID first; otherwise the dialog calls forwarded through it return E_NOTIMPL instead of reaching the PC runtime (no crash). Before this PR the IUnknown query was refused outright, so this is an improvement, but the path is incomplete. Overlaps: #1593 (older, open) makes the same IUnknown change without the rest (D57 in #1607, with #1615); #2623 (open, newer) rewrites the same forwarding branch so that every IID gets its own clone and the shared object never holds a target; the two conflict, and together the canonical IUnknown object of a forwarding class would never forward. Not duplicates.
performance: none (QueryInterface / QueryApiImpl only).
verdict: not yet: when QueryInterface returns the main object of a forwarding class, fill its forward target (as QueryApiImpl does for the table IID) or answer with the matching alias; and settle the order with #2623.
hardware / tool and model: RTX 4070 SUPER 12 GB (621.24 / 32.0.16.2124), Ryzen 7 7800X3D, 32 GB, Windows 11 Pro 25H2 26200.9974, Rust 1.100.0, debug / Claude app (Claude Opus 5.5): merge, build and suite run on this PC with git and cargo only; diff review by Claude Opus 5.5.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:15:59Z.
Triage (#1607) – head
d3e2053#1593 and #1615 also answer IID_IUnknown in
query_interface(xgameruntime/api.rs). #1615 returnsthis, which breaks COM identity across an object's vtables. #1593 returns the class's main object, as this PR does. This PR also answers sibling interface IIDs and changes the forwarding-alias rule inQueryApiImpl. That rule change is a separate fix and would be easier to review as its own PR. None of the three is on main. #1242 is unrelated (mount handle inmount_with_ui_async).No problems found in the diff.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.