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

Open
opened 2026-11-26 20:20:58 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1328
Author: @robot00f
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: fix/console-heap-alignment


📝 Commits (1)

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

📊 Changes

2 files changed (+33 additions, -1 deletions)

View changed files

📝 runtime/shims/d3d12_xs_device.cpp (+6 -1)
📝 runtime/test/d3d12_console_descriptor_heap_test.cpp (+27 -0)

📄 Description

Claim: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7145591230 (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.)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1328 **Author:** [@robot00f](https://github.com/robot00f) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/console-heap-alignment` --- ### 📝 Commits (1) - [`a55007b`](https://github.com/ubiquitarianism/leonida/commit/a55007b6014d7c19df24d8899c246a5ec3e82d35) d3d12: require a console heap address to be 64 KiB aligned before slot 14 reads it ### 📊 Changes **2 files changed** (+33 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `runtime/shims/d3d12_xs_device.cpp` (+6 -1) 📝 `runtime/test/d3d12_console_descriptor_heap_test.cpp` (+27 -0) </details> ### 📄 Description Claim: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7145591230 (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.) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1358
No description provided.