d3d12: require a console heap address to be 64 KiB aligned before slot 14 reads it #1328

Open
github-bot wants to merge 1 commit from github-bot/gh-1328 into main AGit
Owner

@⁠robot00f on GitHub · 2026-11-24 21:56 UTC · original
robot00f:fix/console-heap-alignment → main · +33 −1 · 2 files · 1 commits · open

Claim: #14 (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.

Tested

  • d3d12_subgroup_test: SegFault 3/3 before, passes 3/3 after.
  • 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.

GPUs tested: NVIDIA GPU (Pascal class, 4 GB), driver 582.28, Windows 10 19045.

AI-assisted: yes (OpenCode, DeepSeek V4.1 Flash)

Checklist

  • Based on current main and merges cleanly.
  • One topic.
  • No game data, keys or decryption (CONTRIBUTING.md).
  • A new translator rule is in the contract table of docs/design.md. (No translator change.)
**@⁠robot00f** on GitHub · 2026-11-24 21:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1328) `robot00f:fix/console-heap-alignment` → `main` · +33 −1 · 2 files · 1 commits · open Claim: https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14 (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. ### Tested - `d3d12_subgroup_test`: SegFault 3/3 before, passes 3/3 after. - `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. GPUs tested: NVIDIA GPU (Pascal class, 4 GB), driver 582.28, Windows 10 19045. AI-assisted: yes (OpenCode, DeepSeek V4.1 Flash) ### Checklist - [x] Based on current main and merges cleanly. - [x] One topic. - [x] No game data, keys or decryption (CONTRIBUTING.md). - [ ] A new translator rule is in the contract table of docs/design.md. (No translator change.)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:47:34 +00:00
Author
Owner

@⁠whoalin1 on GitHub · 2026-11-24 23:08 UTC · original

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).

AMD iGPU (VK_LOADER_DRIVERS_SELECT=*amd-vulkan* LEONIDA_VK_DEVICE=radeon LEONIDA_VK_VALIDATION=1 LEONIDA_PC_TAIL_UBO=1):

  • 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.

— AI-assisted verification

**@⁠whoalin1** on GitHub · 2026-11-24 23:08 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1328#issuecomment-7147058205) 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~). **AMD iGPU** (`VK_LOADER_DRIVERS_SELECT=*amd-vulkan* LEONIDA_VK_DEVICE=radeon LEONIDA_VK_VALIDATION=1 LEONIDA_PC_TAIL_UBO=1`): - 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. — AI-assisted verification
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1328/head:github-bot/gh-1328'
git switch 'github-bot/gh-1328'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1328'
git switch 'github-bot/gh-1328'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1328'
git switch 'github-bot/gh-1328'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1328'
git switch 'main'
git merge --squash 'github-bot/gh-1328'
git switch 'main'
git merge --ff-only 'github-bot/gh-1328'
git switch 'main'
git merge 'github-bot/gh-1328'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.