d3d12_xs: only take the console slot-14 layout when the descriptor size agrees #4
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!4
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/4/head"
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?
@yyc160 on GitHub · 2026-11-24 01:16 UTC · original
yyc160:slot14-range-guard→main· +16 −3 · 1 files · 1 commits · merged 2026-11-24 01:26 UTCFixes the false positive in #3.
proxy_create_descriptor_heaptreated a readable, non-zero word after the PC description as a console address. A normal 16-byteD3D12_DESCRIPTOR_HEAP_DESCis almost always followed by readable, non-zero memory, so every ordinary heap created through the proxy entered the console path and reported that word as its CPU handle; the firstCreate*Viewthen wrote through it.The console layout carries a size as well as an address, and that size is 32 bytes per descriptor. A PC desc's trailing words are whatever the caller holds next and do not encode
NumDescriptors * 32, so requiring the agreement separates the two layouts without guessing anything about the address.I also tried requiring the range to be a committed, writable
VirtualQueryregion. That is a true property of the console layout, but it rejectsd3d12_console_descriptor_heap_test's synthetic address, and a console heap whose VA is not backed by title memory would fail it too, so I left it out. Size alone is enough for the corpus here.Measurements
Windows 11, MSVC 14.44.35207, Windows SDK 10.0.26100.0, Ninja, RTX 5070 Ti with driver 32.0.16.1742. Base is
main@2e4715746; the only difference between the two rows is this commit.main@2e4715746main@2e4715746+ this commitd3d12_descriptorgoes from exit 139 to exit 0. The 18 tests that stop failing are the ones that create a heap through the proxy and then write through the handle:The four that still fail fail identically with and without this change, and are unrelated to descriptor heaps:
root_sig:FAIL blob helper rewrites an all-zero-checksum Xbox blob and keeps its zero checksum,FAIL shim deserializer accepts an all-zero-checksum Xbox blob with the high byte clearedd3d12_com,d3d12_vulkan_device:ExecuteCommandLists failed: a list is not closed; nothing was submittedandinvalid copy or resolve; nothing was submittedd3d12_depth_resolveNothing here quotes the executable: test names, a file:line and pass/fail only.
@wavehs on GitHub · 2026-11-24 01:27 UTC · original
macOS arm64 review (Apple M3 Pro) — the fix is right and it was merged as I was checking it; two things to pin now that the equality decides the dispatch
Read at head
37246f11d, which is whatubi/main30daa6958contains (the merged file is byte-identical to the PR head:git diff 37246f11d ubi/main -- runtime/shims/d3d12_xs_device.cppis empty). Host: macOS 27.2.1, Apple M3 Pro (arm64), CPython 3.15.2.git diff 2e4715746 37246f11d(branch point → head)runtime/shims/d3d12_xs_device.cpp; the README hunk in the PR diff is the branch being behindmain, not part of the changegit merge-tree --write-tree 30daa6958 37246f11dpython3 -I scripts/run_semantic_tests.py tests/semanticat the headtest_exec_computed,test_image_atomics_guard) — identical to unmodifiedmain, as expected:tools/andtests/semantic/are byte-identical betweenubi/mainand this headd3d12_xs_device.cppis aWIN32-only shim, the Vulkan backend is untouched by the change, and the file does not compile on this host at allSo the only thing I can contribute is the arithmetic and what the new predicate now depends on.
The bug is real and the fix is right.
address != 0was not evidence: the two words after a 16-byteD3D12_DESCRIPTOR_HEAP_DESCare whatever the caller holds next, and reading them as a console VA is exactly the kind of check that passes for the wrong reason. Requiringsize == NumDescriptors * 32is a much better discriminator, and the helper is sound at its boundaries:address == 0,size == 0,NumDescriptors == 0, andNumDescriptors > 0xFFFFFFFF/32all reject, so the multiplication cannot wrap. One behaviour change worth knowing: aNumDescriptors == 0heap with a console address now goes to the PC call, which returnsE_INVALIDARGfor a zero-descriptor heap anyway — same outcome, different route.1. The equality is now load-bearing, and the number it encodes is listed as unmeasured in this repository.
docs/d3d12_vulkan.mdsays, twice, that the console's heap increments are open::3916— "Are Xbox descriptor bytes GFX10 T#/S#, and what are the heap increments? … the increment values still need measuring.":3858-3859— "descriptor bytes and heap increments are still Open. Slot 15 is forwarded unchanged, but the actual increment values were not measured."kConsoleDescriptorSize = 32is the PC increment (runtime/shims/d3d12_com.h:418), and the predicate now requires the console's own size word to agree with it exactly. If a retail descriptor heap reports a page-rounded size, or an increment other than 32, the console path silently stops being taken and the boot'sGetCPUDescriptorHandleForHeapStart() == addresscheck fails with the same symptom as the false positive — one layer further from the cause. Nothing else in the tree contradicts that today, but nothing confirms it either:console_size_is parsed, stored and never read (runtime/shims/d3d12_vulkan_device.cpp:1710, 1773), so the only witness to the equality isruntime/test/d3d12_console_descriptor_heap_test.cpp:35-36, which was written to the same assumption (size = 8ull * 32ull).The cheap closure is one
log_onceat the decision point, in the style already used for slot 62's extra words and for the console heap itself:and, separately, one
log_onceon the rejection path whenaddress != 0but the size disagrees. A single retail boot would then turn open question 4 from "Open" into measured for the heap sizes, and a false negative would show up as a line in the trace instead of as a wrong CPU handle in aCreate*View.2. Two 32s that must agree live in two files.
kConsoleDescriptorSizehere vsrt::d3d12::descriptor_size(d3d12_com.h:418, used askDescriptorSizeatd3d12_vulkan_device.cpp:60-65for the heap's own stride). If the descriptor stride ever changes for one heap type, the predicate and the heap disagree with no compiler complaint. Using the existing constant, or a comment naming it, removes that.3. The accept branch has no test.
d3d12_console_descriptor_heap_testcallscreate_console_descriptor_heapdirectly, so it never passes throughproxy_create_descriptor_heap; the new predicate's true branch is pinned by nothing.set_console_descriptor_heap_handler(d3d12_xs_device.h:118) exists for exactly this: install a fake handler, pass a 32-byte desc withsize = 8*32, and assert the handler received the address — otherwise a future tightening can disable the console path with every test still green, which is the mirror image of the bug you just fixed.The remaining false positive needs both trailing words to hold
N*32, which is a drastically weaker coincidence than one non-zero word; a caller that keeps a computedN*32byte count next to the desc is the shape to imagine, and it would have to land in both slots. Your comment says "size alone is enough for the corpus here", which is an honest way to state it.The Windows numbers (278 → 296 of 300) are yours on MSVC/RTX 5070 Ti; I could not reproduce them and did not try.
No game files. AI-assisted.