d3d12: require a console heap address to be 64 KiB aligned before slot 14 reads it #1328
Closed
leonida/mandy
robot00f wants to merge 0 commits from
fix/console-heap-alignment into main
pull from: fix/console-heap-alignment
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!1328
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/console-heap-alignment"
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?
Pull request closed
This pull request cannot be reopened because the branch was deleted.
Claim: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7145591230 (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
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 -j8on both GPUs (TEMP/TMP pointed at the user profile; VK_LOADER_LAYERS_DISABLE=implicit).AMD iGPU (
VK_LOADER_DRIVERS_SELECT=*amd-vulkan* LEONIDA_VK_DEVICE=radeon LEONIDA_VK_VALIDATION=1 LEONIDA_PC_TAIL_UBO=1):d3d12_subgroupfails the same way before and after on this iGPU:pipelines need 144 bytes of push constants ... maxPushConstantsSize 128then the!result.failureassert — 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 newd3d12_console_descriptor_heaptest 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):d3d12_execute_indirect_validation(the known WARP/HW parity diffs; it passed in isolation on baseline) andd3d12_pipeline_library_host(0xc0000409 — reproduces identically on baseline main, pre-existing).d3d12_subgroupandd3d12_console_descriptor_heappass.No game files used. Verified on this machine only.
— AI-assisted verification
Verified by OreoFR
a8465211f+ PR heada55007b60(merged with --no-ff, no conflict; tested in a package with other PRs that share no file with it)ctest -R ^d3d12_console_descriptor_heap$(also xs_proxy_mock)d3d12_console_descriptor_heappasses (no red), andxs_proxy_mockpassed 5/5d3d12_console_descriptor_heapfails every run:writable backing: expected console handlefor a console heap address that is 16-byte but not 64 KiB aligned, so the existing case now gets no console handle.xs_proxy_mockalso 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)runtime/shims/d3d12_xs_device.cppwith the open #2566; a rebase may be needed if #2566 lands first.AI-assisted (Claude Code, Claude Opus 5.5).
#1328 | head a55007b6014d7c19df24d8899c246a5ec3e82d35 (auto-merges cleanly with main 829530dbd0196aa817dbec74aaafc79407b94b57, 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 currentmain(829530dbd0), while the other5/5CTests (device_proxy,xs_proxy_mock,d3d12_descriptor,d3d12_clear,d3d12_typeless_rtv) pass in12.38 son RTX 3090 with0Khronos validation errors: (1)mainsubsequently addedcheck_xs_proxy_slot14(runtime/test/d3d12_console_descriptor_heap_test.cpp:97-125), which passes a stack-allocatedalignas(64) unsigned char storage[4096]{}(64-byte aligned, not64 KiBaligned) throughDeviceProxyslot 14 expectingcheck_start("writable backing", true), andaddress % 0x10000rejects it (note alsod3d12_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 always64 KiBaligned vs64 B/4 KiBaligned before tighteningcheck_xs_proxy_slot14toVirtualAlloc), and (2)check_unaligned_tail_is_not_a_console_heap(device.get())callsCreateDescriptorHeapon the unwrapped VulkanID3D12Deviceinstead of thed3d12_xsDeviceProxyslot 14, andmain(d3d12_xs_device.cpp:4805) now checksaccessible_range(..., true)so unmapped0x65626f72705f7370ull("ps_probe") is already rejected onmain;check_no_game_data.py0violations | Windows 11, MSVC 19.44, RTX 3090, Vulkan SDK 1.4.363.1 | AI-assisted: yesIndependent verification on this machine (Windows 11, RTX 4090, MSVC 19.44.35226): this pull request applies, builds, and its own test fails - deterministically.
1. It applies.
merge-treeclean;a55007b60cherry-picks ontomaine236b19c6without a conflict. Two files:runtime/shims/d3d12_xs_device.cpp(the fix) andruntime/test/d3d12_console_descriptor_heap_test.cpp(the check).2. The target builds:
3. The test fails, twice, with the same message:
4. On
main, the same test target passes - so this is the branch's own check failing on the branch's own tree, not a pre-existing red.What the addresses suggest, and I am flagging it as a suggestion rather than a diagnosis: the console address in both runs ends in
0x340and0x2c0- neither is 64 KiB aligned, and the commit is titled "require a console heap address to be 64 KiB aligned before slot …". So either the fix does not produce the alignment the test then demands, or the check reads the address before the fix rewrites it. The two runs got different addresses (ASLR), so this is not one unlucky allocation.What I did not do: change the test or the shim to see which of the two is wrong. That is the author's call, and a stranger editing either would be guessing at intent.
How it was found: a sweep of open pull requests that replay onto
main, building what each test'scommand[0]says, and running it throughctest -R. Of the 25 in this batch, this is the only one whose test fails; five built and passed.Written with an AI assistant.
Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (
d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools,d3d12/, or general docs), please feel free to reopen it.