d3d12_xs: slot 14 does not take an address in the first 64 KiB as a console heap; d3d12_draw no longer SEGFAULTs (D3D-SLOT14-TAIL-NULL-PAGE) #1148

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

@⁠Luna-OS on GitHub · 2026-11-24 19:12 UTC · original
Luna-OS:fix/slot14-tail-null-page → main · +31 −3 · 2 files · 1 commits · open

Claimed in the coordination issue as: D3D-SLOT14-TAIL-NULL-PAGE (#14)

Depends on: none. Touches the same function's neighbourhood as #644 (heap sync) and the same decision as the stale draft #216 (choosing the slot-14 layout per device proxy, which would remove the guess altogether); this is the minimal fix for main until that lands.

What and why

d3d12_draw SEGFAULTs on main (seen at 3295055) with MSVC RelWithDebInfo when glslang is available, so the test is built:

[rt] d3d12: descriptor heap uses console address/size (not backed by title memory) 2
249 - d3d12_draw (SEGFAULT)

It is the false positive of #3 again, past the size check #4 added. proxy_create_descriptor_heap reads the 16 bytes after a D3D12_DESCRIPTOR_HEAP_DESC as a console address/size pair when console_heap_range_plausible agrees. The test's ordinary one-entry RTV heap (runtime/test/d3d12_draw_test.cpp:351) had, measured with a temporary log at that call:

slot14 tail address=0x1 size=32 n=1

32 == 1 * 32, so the size check passed, the heap's start became 0x1, and CreateRenderTargetView wrote through it. For a one-descriptor heap a stray 32 next to the desc is not unlikely.

The fix: console_heap_range_plausible also requires the address to be at least 0x10000. Windows never maps the first 64 KiB (the lowest user-mode address is 0x10000), so no console heap address can be there. Real console addresses (0x556677880000 and 0x112233440000 in the existing test) are unaffected. d3d12_console_descriptor_heap_test gets the measured case: an RTV desc with NumDescriptors = 1 followed by 1, 32 must give an ordinary heap through the proxy.

Tested

Windows 11 Pro 26300, NVIDIA GeForce RTX 5070 Ti (621.24), MSVC 19.44.35207, Ninja, RelWithDebInfo, glslang (KhronosGroup main-tot) on PATH via Vulkan_GLSLANG_VALIDATOR_EXECUTABLE. No game files.

without the fix with the fix
d3d12_console_descriptor_heap (with the new case) Failed: stray trailing words were taken as a console heap: CPU start 0x1 Passed
d3d12_draw SEGFAULT Passed
full ctest 296/298 298/299; the one failure is d3d12_execute_indirect_validation (#504), as on main

d3d12_descriptor (the test of #3) passes in both.

GPUs tested: NVIDIA GeForce RTX 5070 Ti, driver 621.24, Windows 11 26300 (plus live WARP in the tests that use it)

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly.
  • One topic.
  • No game data, keys or decryption.
  • No translator rule changed.

🤖 Generated with Claude Code

**@⁠Luna-OS** on GitHub · 2026-11-24 19:12 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1148) `Luna-OS:fix/slot14-tail-null-page` → `main` · +31 −3 · 2 files · 1 commits · open Claimed in the coordination issue as: D3D-SLOT14-TAIL-NULL-PAGE (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) Depends on: none. Touches the same function's neighbourhood as #644 (heap sync) and the same decision as the stale draft #216 (choosing the slot-14 layout per device proxy, which would remove the guess altogether); this is the minimal fix for `main` until that lands. ### What and why `d3d12_draw` SEGFAULTs on `main` (seen at `3295055`) with MSVC RelWithDebInfo when glslang is available, so the test is built: ``` [rt] d3d12: descriptor heap uses console address/size (not backed by title memory) 2 249 - d3d12_draw (SEGFAULT) ``` It is the false positive of #3 again, past the size check #4 added. `proxy_create_descriptor_heap` reads the 16 bytes after a `D3D12_DESCRIPTOR_HEAP_DESC` as a console address/size pair when `console_heap_range_plausible` agrees. The test's ordinary one-entry RTV heap (`runtime/test/d3d12_draw_test.cpp:351`) had, measured with a temporary log at that call: ``` slot14 tail address=0x1 size=32 n=1 ``` `32 == 1 * 32`, so the size check passed, the heap's start became `0x1`, and `CreateRenderTargetView` wrote through it. For a one-descriptor heap a stray `32` next to the desc is not unlikely. The fix: `console_heap_range_plausible` also requires the address to be at least `0x10000`. Windows never maps the first 64 KiB (the lowest user-mode address is `0x10000`), so no console heap address can be there. Real console addresses (`0x556677880000` and `0x112233440000` in the existing test) are unaffected. `d3d12_console_descriptor_heap_test` gets the measured case: an RTV desc with `NumDescriptors = 1` followed by `1, 32` must give an ordinary heap through the proxy. ### Tested Windows 11 Pro 26300, NVIDIA GeForce RTX 5070 Ti (621.24), MSVC 19.44.35207, Ninja, RelWithDebInfo, glslang (KhronosGroup `main-tot`) on PATH via `Vulkan_GLSLANG_VALIDATOR_EXECUTABLE`. No game files. | | without the fix | with the fix | |---|---|---| | `d3d12_console_descriptor_heap` (with the new case) | Failed: `stray trailing words were taken as a console heap: CPU start 0x1` | Passed | | `d3d12_draw` | SEGFAULT | Passed | | full `ctest` | 296/298 | 298/299; the one failure is `d3d12_execute_indirect_validation` (#504), as on `main` | `d3d12_descriptor` (the test of #3) passes in both. GPUs tested: NVIDIA GeForce RTX 5070 Ti, driver 621.24, Windows 11 26300 (plus live WARP in the tests that use it) AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic. - [x] No game data, keys or decryption. - [x] No translator rule changed. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
d3d12_draw SEGFAULTed with MSVC RelWithDebInfo: its one-entry RTV desc was
followed on the stack by the words 1 and 32, which console_heap_range_plausible
accepted (32 == 1 * 32), so the RTV heap started at 0x1 and
CreateRenderTargetView wrote through it. Windows never maps the first 64 KiB
and no console heap lives there; reject such addresses.
d3d12_console_descriptor_heap_test gets the stray-words case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:40:18 +00:00
Author
Owner

@⁠madhyn on GitHub · 2026-11-24 19:19 UTC · original

Tested f6584ed80 on Arch Linux + Wine 11.22 + NVIDIA RTX 3060 Ti (clang-cl + xwin cross-build):

  • d3d12_console_descriptor_heap: Passed (5.54 s)
  • d3d12_draw: Passed (5.56 s)
  • xs_proxy_mock, _no_reserve, _no_protect, _no_handler, _env_slots: Passed (note: xs_proxy_mock_env_slots_invalid fails on slot 71, same as current main)

AI-assisted: yes

**@⁠madhyn** on GitHub · 2026-11-24 19:19 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1148#issuecomment-7141927972) Tested `f6584ed80` on Arch Linux + Wine 11.22 + NVIDIA RTX 3060 Ti (clang-cl + xwin cross-build): - `d3d12_console_descriptor_heap`: **Passed** (5.54 s) - `d3d12_draw`: **Passed** (5.56 s) - `xs_proxy_mock`, `_no_reserve`, `_no_protect`, `_no_handler`, `_env_slots`: **Passed** (note: `xs_proxy_mock_env_slots_invalid` fails on `slot 71`, same as current `main`) AI-assisted: yes
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 19:21 UTC · original · approved these changes

Reviewed and verified. Essential stability fix in
untime/shims/d3d12_xs_device.cpp:console_heap_range_plausible. Requiring descriptor heap addresses to exceed \kLowestMappedAddress\ (0x10000) prevents stray stack values (e.g. 1 and 32 left on stack under MSVC RelWithDebInfo in \d3d12_draw_test) from falsely matching one-descriptor console heap size checks and crashing with SEGFAULTs at address 0x1. Verified with clean test addition in
untime/test/d3d12_console_descriptor_heap_test.cpp. 100% clean-room.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 19:21 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1148#pullrequestreview-6045824703) · **approved these changes** Reviewed and verified. Essential stability fix in \ untime/shims/d3d12_xs_device.cpp:console_heap_range_plausible\. Requiring descriptor heap addresses to exceed \kLowestMappedAddress\ (0x10000) prevents stray stack values (e.g. 1 and 32 left on stack under MSVC RelWithDebInfo in \d3d12_draw_test\) from falsely matching one-descriptor console heap size checks and crashing with SEGFAULTs at address 0x1. Verified with clean test addition in \ untime/test/d3d12_console_descriptor_heap_test.cpp\. 100% clean-room.
Author
Owner

@⁠Deedlyy on GitHub · 2026-11-24 20:13 UTC · original

Recommendation: [MERGE]

Reasoning: Slot 14 no longer treats an address in the first 64 KiB as a console heap, which fixes the d3d12_draw SEGFAULT on main. Minimal fix (+7/-3) with a regression test; it is an interim fix until the per-device layout choice from #216 lands. Verified on Wine + RTX 3060 Ti by madhyn (d3d12_draw and the descriptor heap tests pass). CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main. Merge once the queued checks are green.

Impact level: 5/10

**@⁠Deedlyy** on GitHub · 2026-11-24 20:13 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1148#issuecomment-7143204524) **Recommendation:** [MERGE] **Reasoning:** Slot 14 no longer treats an address in the first 64 KiB as a console heap, which fixes the `d3d12_draw` SEGFAULT on main. Minimal fix (+7/-3) with a regression test; it is an interim fix until the per-device layout choice from #216 lands. Verified on Wine + RTX 3060 Ti by madhyn (`d3d12_draw` and the descriptor heap tests pass). CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with `main`. Merge once the queued checks are green. **Impact level:** 5/10
Author
Owner

@⁠BubsMcgee on GitHub · 2026-11-25 12:37 UTC · original

Tested the code fix on current main 0d80bc5df (Windows 11 Pro build 26300, MSVC RelWithDebInfo, NVIDIA RTX 3080 Ti, driver 616.64):

Applied the runtime/shims/d3d12_xs_device.cpp hunk (the kLowestMappedAddress / 0x10000 guard). Results with the fix:

  • d3d12_draw — Passed
  • d3d12_console_descriptor_heap — Passed
  • d3d12_descriptor — Passed
  • d3d12_set_descriptor_heaps — Passed

On this machine the SEGFAULT does not reproduce on clean 0d80bc5df either (d3d12_draw passes without the fix), so whether the stray 1, 32 words land next to the desc is stack-layout dependent; madhyn's Wine / RTX 3060 Ti run is the reproduction. This is therefore a non-regression check for the fix, not a local repro.

The code hunk applies cleanly. The test hunk conflicts because main's check_xs_proxy_slot14 was reworked since this branch, so it needs a rebase. The stray case fits main's check_start(label, uses_console_address) helper as:

console.desc.NumDescriptors = 1;
console.address = 1;
console.size = 32;
if (!check_start("stray trailing words", false)) return false;

The fix looks good and is harmless: it only rejects console-heap addresses below 0x10000, which Windows never maps. AI-assisted.

**@⁠BubsMcgee** on GitHub · 2026-11-25 12:37 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1148#issuecomment-7162628006) Tested the code fix on current `main` `0d80bc5df` (Windows 11 Pro build 26300, MSVC RelWithDebInfo, NVIDIA RTX 3080 Ti, driver 616.64): Applied the `runtime/shims/d3d12_xs_device.cpp` hunk (the `kLowestMappedAddress` / `0x10000` guard). Results **with the fix**: - `d3d12_draw` — Passed - `d3d12_console_descriptor_heap` — Passed - `d3d12_descriptor` — Passed - `d3d12_set_descriptor_heaps` — Passed On this machine the SEGFAULT does not reproduce on clean `0d80bc5df` either (`d3d12_draw` passes without the fix), so whether the stray `1, 32` words land next to the desc is stack-layout dependent; madhyn's Wine / RTX 3060 Ti run is the reproduction. This is therefore a non-regression check for the fix, not a local repro. The code hunk applies cleanly. The test hunk conflicts because main's `check_xs_proxy_slot14` was reworked since this branch, so it needs a rebase. The stray case fits main's `check_start(label, uses_console_address)` helper as: ```cpp console.desc.NumDescriptors = 1; console.address = 1; console.size = 32; if (!check_start("stray trailing words", false)) return false; ``` The fix looks good and is harmless: it only rejects console-heap addresses below `0x10000`, which Windows never maps. AI-assisted.
Author
Owner

@⁠BubsMcgee on GitHub · 2026-11-25 13:03 UTC · original

@⁠Luna-OS The code fix is verified on an RTX 3080 Ti (above), but the PR still conflicts with main's reworked check_xs_proxy_slot14. The stray case fits main's check_start helper (snippet above). Could you rebase? Happy to help. (AI-assisted.)

**@⁠BubsMcgee** on GitHub · 2026-11-25 13:03 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1148#issuecomment-7163236280) @⁠Luna-OS The code fix is verified on an RTX 3080 Ti (above), but the PR still conflicts with main's reworked check_xs_proxy_slot14. The stray case fits main's check_start helper (snippet above). Could you rebase? Happy to help. (AI-assisted.)
This pull request has changes conflicting with the target branch.
  • runtime/test/d3d12_console_descriptor_heap_test.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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