D3D12.X: a list vtable at a reused heap address gets its own methods #2583
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2593"
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 SergeAx on 2026-11-26T00:53:48Z.
Fixes #2588.
With the Agility SDK 1.620, an open command list's vtable is in heap memory and goes with the list.
real::class_forcached the extended vtable by the runtime vtable's address and copied the runtime's methods only once, so a direct list whose open vtable came where a released compute list's had been called the compute list's methods: itsClearDepthStencilViewmadeClosefail withE_FAIL. That is the parallel-only failure ofvram::tests::d32s8_targets_take_their_own_size_of_video_memory(#42).What is in it
crates/xcl/src/hle/d3d12x/real.rs: aClassof a vtable outside any module keeps the methods it copied (copied), andclass_fortakes it only while they are still the ones at that address. Vtables in a module's image are looked up as before.crates/xcl/src/hle/d3d12x/real.rs(class_tests):a_direct_list_at_a_released_compute_lists_vtable_records_with_its_own_methods.Tested
cargo test --workspace --no-fail-fast -- --test-threads=4at52c0802f: 1426 passed, 4 failed, 47 ignored. The 4 are #1905 (fuzz_validate_and_gpu_0.._3, seeds 70, 545, 1019 and 1507), as on main6d12f58(#42).V_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32);heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windowscopied, and passes in 5 out of 5 with this change.--test-threads=4 hle::d3d12x hle::xgameruntime: the D32S8 test failed in 2–5 runs out of 10 on6d12f58, and in 0 out of 12 with this change.Regression run
main:
this PR:
Not tested
D3D12Core.dll, which this change looks up as before)list_x::tests::a_reset_while_the_last_submit_runs_records_on_another_pc_list)AI use
Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-26T01:11:05Z.
Update for the rebased head
49c68f2(onmaine429936): same result on the RX 9070 XT.cargo test -p xcl --lib -- a_direct_list_at_a_released_compute_lists_vtable --nocapture, 5 runs:SKIPPED … no direct list got a released compute list's vtableandokin all 5, so the reuse still doesn't happen on this machine and the fix isn't exercised here.AMD run (listed as untested), on Windows 11 too: on an RX 9070 XT the new test skips. The reuse it waits for did not happen in 3 runs, so on this machine it passes without exercising the fix.
Head
52c0802applied onmainb49be18, debug, Windows 11 Pro 26200, RX 9070 XT (RDNA4, driver 32.0.32029.2010). The test takes the default adapter (create_device(None, ..)), which is the RX 9070 XT on this machine.cargo test -p xcl --lib -- a_direct_list_at_a_released_compute_lists_vtable --nocapture, 3 times, each:So in the test's 200 tries, no direct list landed on a released compute list's vtable address here. Your report's SKIPPED list doesn't include this test, so it did run on the RTX 5080. Whether the address reuse is rarer here because of the GPU driver, Windows 11 or the heap was not looked into. This run also says nothing about whether the fix is right on AMD; it only shows the test does not reach it on this machine.
Not tested: the machine's RTX 3060 (the test always uses the default adapter), Intel, a title.
AI use: Claude Code (Claude Opus 5.5) ran the test on this machine and wrote this report.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T01:09:50Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.Thanks!
— Devin
Imported from ivall/xcl. Originally posted by mokkamokacaffe on 2026-11-26T01:29:51Z.
I found an additional cache-boundary case in the current implementation.
same_methodswalks the historicalcopied.len()before deriving the replacement vtable’s current interface and scanned length. A shorter replacement can therefore be read using the older length, while a longer table sharing the old prefix can reuse stale internal method handling.I prepared a focused follow-up at
ea5a19a. It derives the live table shape first, compares the complete snapshot and metadata, preserves the image-backed fast path, and adds CPU-only coverage for:Tested
heap_classes_match_only_the_same_shape_and_methods: passedgit diff --check: passedNot tested
xcl-smokerunsExact-head GPU and smoke runs remain required after this change is folded into #2593.
AI use
Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-26T05:13:32Z.
Tested: current PR head merged onto current
origin/main(clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo targetx86_64-pc-windows-gnurun under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).gpu_suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.Targeted run of
a_direct_list_at_a_released_compute_lists_vtable_records_with_its_own_methods: passed.Not tested: retail titles (no title data on this lane, counts only).
AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
Imported from ivall/xcl. Originally posted by SergeAx on 2026-11-26T05:31:01Z.
@mokkamokacaffe thanks for looking. I read
class_forat52c0802andea5a19a, and I don't think the extra check is needed:same_methodsreadscopied.len()words atorig: the old class'sscanned, the same words its own scan read at that address. A class is reused only when all of those words equal its snapshot; a fresh scan would then find the same words in the same module and stop no earlier, so the table cannot come out shorter.scanned, where the old scan stopped, now points into the same module. With the firstscannedwords identical, it is the same runtime class, whose table length is fixed: a word after it is heap memory past the vtable, not a method. The runtime calls only its own methods, all among the compared words, and for the title such a slot answers the same either way: the guard of an internal slot answers a title call as the stub does (logged, 0), andconsole_slots/console_remapgive it the same handler in both cases.CLASSESand the lookup matches by methods, so A's class is found again when A's table comes back.ea5a19aruns the QI probe and the scan on every adopt of an object with a heap vtable before matching (every command list on Agility 1.620), where this PR comparesscannedwords. Its new test covers the newmatching_classhelper; it does not show a case where this PR's lookup returns the wrong class. So I'm keeping #2593 as it is.AI use: Claude Code (Claude Opus 5.5) read both commits and wrote this reply.
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T06:48:41Z.
NVIDIA test report for
52c0802: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug.a_direct_list_at_a_released_compute_lists_vtable_records_with_its_own_methods,--exact --test-threads=1 --nocapture, 5 runs: 5 passed; the reuse happened (no SKIPPED line) in 0 of 5, so it skipped as on the RX 9070 XT. The cause here is the D3D12 runtime, not the driver: with no Agility SDK found,create_deviceused the inboxD3D12Core.dll10.0.26100.9549, whose command list vtables are in the DLL image (PC vtable D3D12Core.dll+0x30ed90/+0x30e830). Compute and direct lists then have different static vtables, andcopiedis never set.XCL_D3D12_DIRset to the Agility SDK 1.620.2 (NuGetMicrosoft.Direct3D.D3D121.620.2), 5 runs: 5 passed; the list vtables were heap addresses, and the reuse happened (no SKIPPED line) in 4 of 5, so the fix is exercised on this driver. With the lookup changed to ignorecopied(local edit, Agility 1.620.2), it failed 5 of 5:ClearDepthStencilView of a direct list at a compute list's vtable 0x... failed its Close.hle::d3d12x::real::at default threads, inbox runtime, 3 runs: 60 passed, 0 failed each time; the new test SKIPPED in all 3.cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4(thehle::xaudio2tests hang on this machine, onmaintoo), inbox runtime: 1296 passed, 0 failed, 27 ignored; 26 SKIPPED lines (21 × no wave64; 3 × wave32 per-lane form refused:V_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32;pso_measurement_compiles_an_exact_synthetic_record: driver cache needs Developer Mode; and the new test).The RX 9070 XT report doesn't say which D3D12 runtime it loaded; if it was the inbox one, its skip has the same cause, and a run with
XCL_D3D12_DIRwould show whether AMD reuses the address.Lib tests only; no title run.
AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by mokkamokacaffe on 2026-11-26T11:35:41Z.
@SergeAx Thanks for the detailed correction. I re-read
class_forat52c0802alongsideea5a19a, and I agree that my follow-up did not establish a failing case in this PR:scannedsnapshot to match.CLASSESand is selected by its method snapshot.matching_classpolicy itself; it did not reproduce an incorrect class selection by the existing lookup.I therefore withdraw the
ea5a19asuggestion and support keeping #2593 scoped as it is. The later Agility 1.620.2 NVIDIA report also gives the important missing distinction: the regression is exercised with heap-backed vtables, while inbox-runtime/image-backed tables legitimately skip it.Thanks for checking the proposed follow-up closely.
AI use
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-26T12:30:03Z.
Independent Windows/NVIDIA test of head
52c0802fb8f13c4efef3b82a14bc34fd338ae7a6. Setup: Windows 11 build 26300, RTX 3080 Ti (621.35), Ryzen 7 9800X3D, rustc 1.99.1, debug; Microsoft's signed Agility SDK 1.620.2 supplied throughXCL_D3D12_DIR.a_direct_list_at_a_released_compute_lists_vtable_records_with_its_own_methodstest passed in 5/5 fresh processes. It exercised the reused heap-vtable address in 3/5; the other two printedSKIPPED: no direct list got a released compute list's vtableand do not count as exercising the fix.cargo build --offline --locked --workspace: passed.cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4: 1,428 passed, 2 failed, 47 ignored across 37 targets. There were 25 GPU SKIPPED notices (21 no wave64, 3 refused per-lane forms, 1 no heap windows); these tests are included in Cargo's passing count, not GPU coverage. The two failures werefuzz_validate_and_gpu_3(driver0x8007000Eat seed 1904) andconsole_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk(DXIL not compiled yet). The new vtable test passed in this suite too.On exact
mainbaseb49be18, the shader-cache test failed alone with the sameDXIL not compiled yeterror. The GPU fuzz test passed alone on base and in 3/3 isolated reruns on the PR head. A matched full base suite did not finish: four parallel GPU tests ran over 60 seconds without further output, so I stopped it. I cannot classify the suite's fuzz failure as a PR regression or declare the PR merge-ready from these runs.No retail title, AMD, or Intel test. AI use: Codex (GPT-6.2 Sol) prepared the exact-head builds, ran the tests, and checked the logs.
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-27T00:04:09Z.
Independent desktop NVIDIA verification of PR #2593 at head
52c0802fb8f13c4efef3b82a14bc34fd338ae7a6(1commit; exact parent & merge-base:08db8020d323bf478964fcc586152cce54959cfc, pre-#2555ancestor ofmain).Environment
7956 MiBreported by D3D12), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)D3D12Core.dll10.0.26100.8328(no Agility SDK 1.620+ DLL installed on this host)31.9 GiBusable), Windows 11 Home26200(Developer Mode off)rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC1.9.2609.5,--releaseTargeted release tests & build (
52c0802f)cargo test --release -p xcl a_direct_list_at_a_released_compute_lists_vtable_records_with_its_own_methods -- --nocapture(5 consecutive runs)1 passed; 0 failed; 0 ignored; 1331 filtered out× 5 (0.19s× 5) — self-skipped on all 5 runs viaskip_test("no direct list got a released compute list's vtable")because inboxD3D12Core.dll10.0.26100.8328places open command-list vtables inside the module image (D3D12Core.dll+0x30bd90,D3D12Core.dll+0x30b830) rather than on the heapcargo test --release -p xcl hle::d3d12x::real:: -- --test-threads=1(3 consecutive runs)60 passed; 0 failed; 0 ignored; 1272 filtered out× 3 (2.05s× 3;59executed +1self-skippedclass_testscase above)cargo build --release -p xcl0,0new warnings)Paired quiet 60 s retail smoke (
title: 29640639)Exact parent & merge-base (
08db8020d323bf478964fcc586152cce54959cfc, cached baseline on the same machine):PR #2593 (
52c0802fb8f13c4efef3b82a14bc34fd338ae7a6):Runtime log observations (
xcl.log)9223log lines,0[ERROR]/ device-removal / panic lines.13D3D12 runtime vtables adopted during the run, all inside inboxD3D12Core.dll(module_of(orig) != 0fast path).19537 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample13977 MB committed by the process; video memory 6115 MB local, 4652 MB non-local.Limits of coverage
D3D12Core.dll(10.0.26100.8328) without Agility SDK 1.620+, so open command-list vtables live insideD3D12Core.dll(module_of(orig) != 0) instead of heap memory. As a result,a_direct_list_at_a_released_compute_lists_vtable_records_with_its_own_methodsself-skipped (5/5standalone,3/3insidehle::d3d12x::real::) and did not execute theClearDepthStencilView+Close()assertion on a reused heap vtable address.Class::copied/same_methods/module_of(orig) == 0guard builds cleanly and causes no regression on inboxD3D12Core.dll(59executedhle::d3d12x::real::tests × 3 and paired 60 s retail smoke ontitle: 29640639); independent hardware verification of the heap-vtable reuse fix itself still requires a host with Agility SDK 1.620+ loaded.AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:26:20Z.
Triage (#1607) – head
49c68f2No open or merged PR makes the same change. On main,
real::class_forstill reuses a cachedClasskeyed only on(orig, kind), so a heap vtable address that a freed list's vtable used gets that list's methods (#2588). #2691 (closed) tried to forget the list instead.This PR keeps a copy of the methods for vtables outside any module and matches a class only while they are still the same. The GPU test skips itself when no direct list lands on a released compute list's vtable, so it does not always cover the path.
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.