D3D12.X: a direct list at a released compute list's heap vtable address gets the compute list's methods #2578

Open
opened 2026-11-26 00:31:03 +00:00 by SergeAx · 0 comments
SergeAx commented 2026-11-26 00:31:03 +00:00 (Migrated from github.com)
Contributor

Imported from ivall/xcl. Originally posted by SergeAx on 2026-11-26T00:31:03Z.


With the D3D12 Agility SDK 1.620, an open command list's vtable lives in heap memory and is freed with the list. real::class_for (hle/d3d12x/real.rs) caches an adopted object's extended vtable by the runtime vtable's address, and copies the runtime's methods into it only the first time it sees that address. When a direct list's open vtable lands where a released compute list's was, the direct list gets the compute list's methods: its ClearDepthStencilView makes Close fail with E_FAIL.

This is why hle::d3d12x::vram::tests::d32s8_targets_take_their_own_size_of_video_memory fails now and then in parallel runs (Close().unwrap() at vram.rs:2040 → 0x80004005, reported in #42).

Found on

  • NVIDIA GeForce RTX 5080, driver 621.14; Windows 10 22H2 (19045.6466), Agility SDK 1.620.2; main 6d12f58, debug

Measured

  • The lib test binary run as --test-threads=4 hle::d3d12x hle::xgameruntime (or hle::kernelx instead of hle::xgameruntime) fails that test in 2–5 runs out of 10. It never fails with the tests run one at a time, or with any single d3d12x submodule added.
  • While it fails, a ClearDepthStencilView on any DSV (also a new committed D32S8 target in a new heap) fails its Close. The other commands of the test close fine, and the device is not removed.
  • In 3 of 3 failing runs, the failing list's open runtime vtable had first been seen by class_for on a list of type 2 (compute).
  • A test that creates a compute list, releases it, and records a depth clear on a direct list that gets the same open vtable address fails in 5 runs out of 5 with the device adopted, and passes in 5 out of 5 without adopting it. At that address the runtime's slot 47 (ClearDepthStencilView) changes from the compute list's method to the direct list's. XCL's copy keeps the compute list's.

Plan
A class made for a vtable outside any module keeps the runtime methods it copied, and class_for takes it only while they are still the ones at that address. Vtables in a module's image are looked up as before, at no extra cost. That test becomes the regression test.

AI use: found with Claude Code (Claude Opus 5.5), which ran the measurements above and wrote this issue.

<!-- greyfinch-sync:ivall/xcl:issue:6616705934 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/2588). Originally posted by [SergeAx](https://github.com/SergeAx) on 2026-11-26T00:31:03Z. --- With the D3D12 Agility SDK 1.620, an open command list's vtable lives in heap memory and is freed with the list. `real::class_for` (`hle/d3d12x/real.rs`) caches an adopted object's extended vtable by the runtime vtable's address, and copies the runtime's methods into it only the first time it sees that address. When a direct list's open vtable lands where a released compute list's was, the direct list gets the compute list's methods: its `ClearDepthStencilView` makes `Close` fail with `E_FAIL`. This is why `hle::d3d12x::vram::tests::d32s8_targets_take_their_own_size_of_video_memory` fails now and then in parallel runs (`Close().unwrap()` at `vram.rs:2040` → `0x80004005`, reported in #42). **Found on** - NVIDIA GeForce RTX 5080, driver 621.14; Windows 10 22H2 (19045.6466), Agility SDK 1.620.2; main `6d12f58`, debug **Measured** - The lib test binary run as `--test-threads=4 hle::d3d12x hle::xgameruntime` (or `hle::kernelx` instead of `hle::xgameruntime`) fails that test in 2–5 runs out of 10. It never fails with the tests run one at a time, or with any single `d3d12x` submodule added. - While it fails, a `ClearDepthStencilView` on any DSV (also a new committed D32S8 target in a new heap) fails its `Close`. The other commands of the test close fine, and the device is not removed. - In 3 of 3 failing runs, the failing list's open runtime vtable had first been seen by `class_for` on a list of type 2 (compute). - A test that creates a compute list, releases it, and records a depth clear on a direct list that gets the same open vtable address fails in 5 runs out of 5 with the device adopted, and passes in 5 out of 5 without adopting it. At that address the runtime's slot 47 (`ClearDepthStencilView`) changes from the compute list's method to the direct list's. XCL's copy keeps the compute list's. **Plan** A class made for a vtable outside any module keeps the runtime methods it copied, and `class_for` takes it only while they are still the ones at that address. Vtables in a module's image are looked up as before, at no extra cost. That test becomes the regression test. AI use: found with Claude Code (Claude Opus 5.5), which ran the measurements above and wrote this issue.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl#2578
No description provided.