Repository navigation
XGameRuntime: forward every IID of a forwarding class through its own clone (#2399) - #2623
kotekompotek wants to merge 1 commit into
Conversation
… clone (xcl-dev#2399) QueryApiImpl filled a forwarding class's shared Obj.pc from the load/store pair in the known-IID path: two concurrent queries could both call pc_object and leak the loser's COM reference, and an Obj whose iids merge several interface versions would reuse a PC object made for the wrong vtable length (a read past its end in forward()). forward_alias_obj already makes a per-IID clone with its own PC object under the alias map's lock; routing known IIDs through it too closes both holes – the shared Obj's pc stays empty.
|
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
Not tested: the whole suite with this PR, a title. |
|
Test report: AMD RX 7800 XT, exact head Hardware / setup
Tested
Causal control for the new test (local only, not proposed for the PR) Not tested
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
left a comment
There was a problem hiding this comment.
Could the cache-hit path retry the PC query while a forwarding clone's pc is zero? The first pc_object(&c, &i) can fail temporarily, but forward_alias_obj inserts that clone with pc=0 and 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 returns None once and a valid object next would cover recovery. Source review only at head 41e715e5; I did not reproduce a live runtime failure. AI-assisted with Codex (GPT-6.2 Sol).
|
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
Thanks! — Devin |
QueryApiImplfilled 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