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

Closed
Luna-OS wants to merge 1 commit from upstream-pr/1148 into main
Luna-OS commented 2026-11-24 19:12:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Luna-OS on 2026-11-24T19:12:53Z.


Claimed in the coordination issue as: D3D-SLOT14-TAIL-NULL-PAGE (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7141490109)

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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5478653784 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1148). Originally posted by [Luna-OS](https://github.com/Luna-OS) on 2026-11-24T19:12:53Z. --- Claimed in the coordination issue as: D3D-SLOT14-TAIL-NULL-PAGE (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7141490109) 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)
madhyn commented 2026-11-24 19:19:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by madhyn on 2026-11-24T19:19:27Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7141927972 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1148#issuecomment-7141927972). Originally posted by [madhyn](https://github.com/madhyn) on 2026-11-24T19:19:27Z. --- 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
abnalstlll-byte commented 2026-11-24 19:21:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T19:21:44Z.

Review: APPROVED


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045824703 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1148#pullrequestreview-6045824703). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T19:21:44Z. **Review:** APPROVED --- 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.
Deedlyy commented 2026-11-24 20:13:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Deedlyy on 2026-11-24T20:13:03Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7143204524 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1148#issuecomment-7143204524). Originally posted by [Deedlyy](https://github.com/Deedlyy) on 2026-11-24T20:13:03Z. --- **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
BubsMcgee commented 2026-11-25 12:37:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by BubsMcgee on 2026-11-25T12:37:23Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7162628006 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1148#issuecomment-7162628006). Originally posted by [BubsMcgee](https://github.com/BubsMcgee) on 2026-11-25T12:37:23Z. --- 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.
BubsMcgee commented 2026-11-25 13:03:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by BubsMcgee on 2026-11-25T13:03:44Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7163236280 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1148#issuecomment-7163236280). Originally posted by [BubsMcgee](https://github.com/BubsMcgee) on 2026-11-25T13:03:44Z. --- @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.)
MoonEyes commented 2026-11-28 02:54:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T02:54:07Z.


Hi @Luna-OS, thanks for this pull request. It currently conflicts with main (conflicting file(s): runtime/test/d3d12_console_descriptor_heap_test.cpp), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232666470 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1148#issuecomment-7232666470). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T02:54:07Z. --- Hi @Luna-OS, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `runtime/test/d3d12_console_descriptor_heap_test.cpp`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
aslan2142 commented 2026-12-01 16:33:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:33:20Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7317800161 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1148#issuecomment-7317800161). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:33:20Z. --- 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.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!1148
No description provided.