You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
d3d12: require a console heap address to be 64 KiB aligned before slot 14 reads it - #1328
Claim: #14 (comment) (ID D3D12-CONSOLE-HEAP-ALIGN; fixes the d3d12_subgroup SegFault in #1150)
d3d12_subgroup crashed deterministically (3/3) in Device::CreateRenderTargetView, writing the 16-byte view to a handle whose value was the ASCII text ps_probe -- the bytes of a shader name.
Cause
Device slot 14 reads a console descriptor heap as a PC D3D12_DESCRIPTOR_HEAP_DESC with an address at +0x10 and a size at +0x18, and keeps console_heap_range_plausible() to tell that layout from a PC desc whose trailing words are whatever the caller's next local holds. That guard checked only that the size equalled NumDescriptors * 32. The test's neighbour happened to supply exactly 32, so the garbage word was accepted as a console address, GetCPUDescriptorHandleForHeapStart returned it, and the first view write went to 0x65626f72705f7370.
Fix
The predicate now also requires the address to be 64 KiB aligned -- what a heap range the title supplies always is, and what a neighbouring local almost never is. Nothing else changes: a real console heap and an ordinary PC heap both behave as before.
d3d12_console_descriptor_heap_test gains the exact case: a desc whose following words are 0x65626f72705f7370 with a matching size, asserting the handle does not become that word.
d3d12_console_descriptor_heap_test 3/3 (covers the aligned console path through the proxy).
No regression: d3d12_clear_test, d3d12_descriptor_test, d3d12_typeless_rtv_test, device_proxy_test, xs_proxy_mock_test all pass.
check_no_game_data.py -> exit 0.
Not tested: the retail executable's slot 14 call sites (no game files run here). The alignment is an assumption about console heap VAs; if a measurement ever shows a title passing an unaligned one, this is where it would show.
Independent verification (AI-assisted, overnight shift worker). Built the PR head (a55007b) and origin/main (51a6074) with the same RelWithDebInfo/Ninja config and ran ctest -C RelWithDebInfo -R d3d12 -j8 on both GPUs (TEMP/TMP pointed at the user profile; VK_LOADER_LAYERS_DISABLE=implicit).
PR head: 92/118 passed, 26 failed. Baseline main: 93/120 passed, 27 failed. Every PR-head failure also fails identically on baseline (the AMD push-constant 144>128 family plus the known xdxr_rt_check BIBHEAP/box16, d3d12_clear NaN, execute_indirect parity, pipeline_library_host 0xc0000409). Baseline's extra failure, d3d12_multi_viewport, does not exist at this PR's base. No regressions.
d3d12_subgroup fails the same way before and after on this iGPU: pipelines need 144 bytes of push constants ... maxPushConstantsSize 128 then the !result.failure assert — the claimed CreateRenderTargetView SegFault does not reproduce here on baseline either (the test stops earlier at the PSO), so the crash fix could not be observed directly, but the new d3d12_console_descriptor_heap test passes and the guard change is a strict tightening (64 KiB alignment AND the existing size check).
NVIDIA RTX 4070 SUPER (VK_LOADER_DRIVERS_SELECT=*nv-vk* LEONIDA_VK_DEVICE=4070):
PR head: 116/118 passed. Failures: d3d12_execute_indirect_validation (the known WARP/HW parity diffs; it passed in isolation on baseline) and d3d12_pipeline_library_host (0xc0000409 — reproduces identically on baseline main, pre-existing). d3d12_subgroup and d3d12_console_descriptor_heap pass.
No game files used. Verified on this machine only.
Red on main: with main's shim and the PR's test, d3d12_console_descriptor_heap passes (no red), and xs_proxy_mock passed 5/5
Green with the PR: d3d12_console_descriptor_heap fails every run: writable backing: expected console handle for a console heap address that is 16-byte but not 64 KiB aligned, so the existing case now gets no console handle. xs_proxy_mock also failed 3 of 10 runs at line 4599 (g_tear.torn == 0 && g_tear.reads > 0), 0 of 5 without this PR's shim change (not proven to be caused by it)
Verdict: FAILS (the 64 KiB alignment requirement breaks an existing console-heap case on current main)
#1328 | head a55007b (auto-merges cleanly with main 829530d, regression on PR + main) | ctest --test-dir runtime/build -C RelWithDebInfo -R "^(d3d12_console_descriptor_heap|d3d12_descriptor|d3d12_clear|d3d12_typeless_rtv|device_proxy|xs_proxy_mock)$" --output-on-failure (LEONIDA_VK_VALIDATION=1) | flagged on PR+main:d3d12_console_descriptor_heapfails (writable backing: expected console handle, got ...) when merged onto current main (829530dbd0), while the other 5/5 CTests (device_proxy, xs_proxy_mock, d3d12_descriptor, d3d12_clear, d3d12_typeless_rtv) pass in 12.38 s on RTX 3090 with 0 Khronos validation errors: (1) main subsequently added check_xs_proxy_slot14 (runtime/test/d3d12_console_descriptor_heap_test.cpp:97-125), which passes a stack-allocated alignas(64) unsigned char storage[4096]{} (64-byte aligned, not 64 KiB aligned) through DeviceProxy slot 14 expecting check_start("writable backing", true), and address % 0x10000 rejects it (note also d3d12_xs_device.cpp:4794-4796: the title carves descriptor heaps out of a larger slot-133 buffer, so worth confirming whether carved sub-heaps are always 64 KiB aligned vs 64 B/4 KiB aligned before tightening check_xs_proxy_slot14 to VirtualAlloc), and (2) check_unaligned_tail_is_not_a_console_heap(device.get()) calls CreateDescriptorHeap on the unwrapped Vulkan ID3D12Device instead of the d3d12_xsDeviceProxy slot 14, and main (d3d12_xs_device.cpp:4805) now checks accessible_range(..., true) so unmapped 0x65626f72705f7370ull ("ps_probe") is already rejected on main; check_no_game_data.py0 violations | Windows 11, MSVC 19.44, RTX 3090, Vulkan SDK 1.4.363.1 | AI-assisted: yes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claim: #14 (comment) (ID
D3D12-CONSOLE-HEAP-ALIGN; fixes thed3d12_subgroupSegFault in #1150)d3d12_subgroupcrashed deterministically (3/3) inDevice::CreateRenderTargetView, writing the 16-byte view to a handle whose value was the ASCII textps_probe-- the bytes of a shader name.Cause
Device slot 14 reads a console descriptor heap as a PC
D3D12_DESCRIPTOR_HEAP_DESCwith an address at +0x10 and a size at +0x18, and keepsconsole_heap_range_plausible()to tell that layout from a PC desc whose trailing words are whatever the caller's next local holds. That guard checked only that the size equalledNumDescriptors * 32. The test's neighbour happened to supply exactly 32, so the garbage word was accepted as a console address,GetCPUDescriptorHandleForHeapStartreturned it, and the first view write went to0x65626f72705f7370.Fix
The predicate now also requires the address to be 64 KiB aligned -- what a heap range the title supplies always is, and what a neighbouring local almost never is. Nothing else changes: a real console heap and an ordinary PC heap both behave as before.
d3d12_console_descriptor_heap_testgains the exact case: a desc whose following words are0x65626f72705f7370with a matching size, asserting the handle does not become that word.Tested
d3d12_subgroup_test: SegFault 3/3 before, passes 3/3 after.d3d12_console_descriptor_heap_test3/3 (covers the aligned console path through the proxy).d3d12_clear_test,d3d12_descriptor_test,d3d12_typeless_rtv_test,device_proxy_test,xs_proxy_mock_testall pass.check_no_game_data.py-> exit 0.Not tested: the retail executable's slot 14 call sites (no game files run here). The alignment is an assumption about console heap VAs; if a measurement ever shows a title passing an unaligned one, this is where it would show.
GPUs tested: NVIDIA GPU (Pascal class, 4 GB), driver 582.28, Windows 10 19045.
AI-assisted: yes (OpenCode, DeepSeek V4.1 Flash)
Checklist