XGameRuntime: forward every IID of a forwarding class through its own clone (#2399) #2623
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!2623
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2623"
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?
@kotekompotek on GitHub · 2026-11-26 02:54 UTC · original
kotekompotek:fix/xgrt-forward-alias→main· +17 −8 · 1 files · 1 commits · openQueryApiImplfilled a forwarding class's sharedObj.pcfrom a load-then-store pair: two concurrent queries for the same class could both callpc_objectand leak the loser's COM reference (a per-IID clone would take the alias-map lock instead). The same sharedObjis also whatlayout()builds when a class'siidsmerge several interface versions: a PC object cached for one version's IID can be reused for another's, andforward()then indexes the PC vtable past its end. Both holes close by routing every IID of a forwarding class throughforward_alias_obj, which already makes a per-IID clone under the alias-map lock – the sharedObjkeepspcempty. No forwarding class in today'sgdk_tablemerges IIDs, so the vtable over-read is latent; the refcount race is reachable onXGameUialone. Fixes #2399.What is in it
QueryApiImpl:!o.iface.forward.is_empty()→forward_alias_obj(o, c, i)unconditionally (crates/xcl/src/hle/xgameruntime/api.rs).a_forwarding_class_answers_with_a_per_iid_clone: queriesXGameUifor a known IID, asserts the title gets a clone (not the sharedObj), that the sharedObj.pcstays empty, and that a repeat query returns the same clone. Fails on the old dispatch ("the title must not get the shared Obj").Tested
cargo test --workspace --no-fail-fast -- --test-threads=4: 1421 passed, 3 failed, 46 ignored (the lib was rerun alone after parallel release builds flaked 8 timing-sensitive tests;cargo test -p xcl --lib: 1296 passed, 3 failed, 26 ignored)a_forwarding_class_answers_with_a_per_iid_clone: okHRESULT/0x80070057, no SM 6.6 PSOs) and reproduce identically onmain; details below.Regression run (0 s, default settings, a retail title)
main:
this PR:
Not tested
hle::d3d12x::vram::tests::gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark,shaders::pipeline_cap_tests::stale_blob_cannot_bypass_the_offline_pipeline_cap,shaders::pipeline_cap_tests::split_compute_program_prebuilds_and_caches_chain_pieces: fail onmainidentically (GTX 1050 is SM 6.5 max; driver answers0x80070057).-Seconds 0produces a clean run; frames shown is 0 in both blocks.AI use
@DarkPanda69 on GitHub · 2026-11-26 03:05 UTC · original
The three GPU tests listed as not tested (they fail on the GTX 1050, which has SM 6.5 at most) pass with this PR on two SM 6.6 cards, an RX 9070 XT and an RTX 3060. The new test passes too.
Head
41e715eapplied onmainb49be18, debug, Windows 11 Pro 26200, card chosen withXCL_ADAPTER, each run with--nocapture:cargo test -p xcl --lib -- <filter>gpu_retire_queue_holds_heap_until_blocked_queue_passes_markpipeline_cap_tests(stale_blob_cannot_bypass_the_offline_pipeline_cap,split_compute_program_prebuilds_and_caches_chain_piecesand the cap test)a_forwarding_class_answers_with_a_per_iid_clonexgameruntimeNot tested: the whole suite with this PR, a title.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@oni-swr on GitHub · 2026-11-26 03:31 UTC · original
Test report: AMD RX 7800 XT, exact head
41e715e5d39fc51ecd0c2227efbf232b67686294, with its exact parente1d84b7d9153f86a97d2ec5d209d196046fc0beaas control. Both were clean detached checkouts (no uncommitted changes), not merged with currentmain(b49be18).Hardware / setup
XCL_NETWORK=0,cargo -j 4, a separateCARGO_TARGET_DIR. The logs showCompiling xclfrom the checkout for each commit. NoXCL_SAMPLE_*variables set (game-data tests do nothing).Tested
cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4(37 test binaries):41e715e: 1423 passed, 1 failed, 46 ignorede1d84b7: 1422 passed, 1 failed, 46 ignoredgpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1(seed 722: res[30] = 0x1, CPU 0x7fffffff, the known #2115). It also fails alone (cargo test -p xcl --lib gpu::dxil::fuzz_tests: 4 passed, 1 failed, 2 ignored) on both commits, so it is not from this PR.f16_programs_on_the_gpu/f32_programs_on_the_gpu(refused, #1426), andheap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).hle::xgameruntime::api::tests::a_forwarding_class_answers_with_a_per_iid_clone: ok on the head, not present on the parent.cargo test -p xcl --lib hle::xgameruntime -- --test-threads=4: head 76 passed, 0 failed; parent 75 passed, 0 failed.ok, not skipped, on this card in the workspace run, on both head and parent:hle::d3d12x::vram::tests::gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark, andshaders::pipeline_cap_tests::stale_blob_cannot_bypass_the_offline_pipeline_capand::split_compute_program_prebuilds_and_caches_chain_pieces.Causal control for the new test (local only, not proposed for the PR)
On a head checkout, I put the parent's dispatch back in
QueryApiImpl(the block that, for a known IID, does a load-then-store onpcand returns the sharedObj, and callsforward_alias_objotherwise) and kept the PR's test.cargo test -p xcl --lib hle::xgameruntime: 75 passed, 1 failed. The failing test isa_forwarding_class_answers_with_a_per_iid_clone, withthe title must not get the shared Obj. With the PR's one-line change restored (the clean head), it passes. So the test is red without the fix and green with it. The working tree was restored (git statusclean).Not tested
scripts/smoke.ps1/ any retail title, so no regression run is given here. Other AMD generations (RDNA2/4) and the concurrent-query refcount race itself: the test checks which object the title gets, not the race.AI use: Claude Code (Claude Sonnet 5.5), coordinated by Codex (gpt-6.2-sol), ran these tests and wrote this report. The results come from the runs above on this machine.
@luckyteagirl on GitHub · 2026-11-26 05:30 UTC · original · reviewed
Could the cache-hit path retry the PC query while a forwarding clone's
pcis zero? The firstpc_object(&c, &i)can fail temporarily, butforward_alias_objinserts that clone withpc=0and every later query returns it without trying the PC runtime again. The known-IID path on main retried on the next query, so a transient initialization failure now leaves that IID using the fallback stub indefinitely. The existing map lock could serialize a retry while preserving the clone's pointer identity. A fixture where PC lookup returnsNoneonce and a valid object next would cover recovery. Source review only at head41e715e5; I did not reproduce a live runtime failure. AI-assisted with Codex (GPT-6.2 Sol).@DavidM1911 on GitHub · 2026-11-26 08:29 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
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.