Skip to content

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
Luna-OS wants to merge 1 commit into
ProjectLeonida:mainfrom
Luna-OS:fix/slot14-tail-null-page
Open

Luna-OS wants to merge 1 commit into
ProjectLeonida:mainfrom
Luna-OS:fix/slot14-tail-null-page

Conversation

@Luna-OS

@Luna-OS Luna-OS commented Nov 24, 2026

Copy link
Copy Markdown

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

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

…onsole heap (D3D-SLOT14-TAIL-NULL-PAGE)

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 <noreply@anthropic.com>
@madhyn

madhyn commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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 abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Deedlyy commented Nov 24, 2026

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

@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

Copy link
Copy Markdown
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants