startup: check the title heap allocation that succeeds #1549

Merged
Asimmimx merged 1 commit from upstream-pr/1556 into main 2026-11-24 14:38:57 +00:00
Asimmimx commented 2026-11-24 13:53:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T13:53:37Z.


Change

Refs #1149. This extends startup_title_heap, the check for src/startup_stubs/title_heap_memory.h. When a descriptor heap's desktop CPU start is not usable as an address (any CBV/SRV/UAV heap, or a heap whose start is tagged), the wrapper allocates plain memory of NumDescriptors × increment bytes. It gives that memory to the executable as the heap's CPU start.

No existing test takes the path where this allocation succeeds:

  • startup_title_heap uses only an allocator that returns 0 and ignores the size it is asked for.
  • startup_title_heap_device_warp creates no view heap. On WARP the sampler, render-target and depth heaps have aligned starts.
  • startup_view_heap_* and startup_null_views_* pass memory of their own.
  • d3d12x_descriptor_*_warp get a plain desktop device.

So three mutants left all of these passing:

  • discarding the allocated address, which would make every view heap created without its own memory fail with E_OUTOFMEMORY;
  • allocate(1);
  • allocate(bytes / 2).

This adds four expectations to the existing rule(). An allocator that succeeds returns 0x20000 and records the size it is asked for. Two cases use hand-worked sizes:

  • an aligned view heap, 1024 × 32 = 0x8000 bytes;
  • a tagged sampler heap, 128 × 32 = 0x1000 bytes.

Each call must return true, store 0x20000, ask for exactly that size, and advance the allocation count to 2 and then 3.

Only tests/startup_title_heap_check.cpp (+18 lines) and two sentences in the existing title-heap bullet of docs/startup-runtime.md change. There is no CMake change and no new CTest. The existing startup_title_heap_tags_control still fails as intended.

A behaviour I did not pin. WARP's CreateDescriptorHeap accepts NumDescriptors = 0 for all four heap types; I checked this with a scratch probe that is not committed. Such a heap is therefore reachable from the real caller. When it needs memory and has none of its own, title_heap_memory skips the allocation and returns false, so the wrapper returns E_OUTOFMEMORY although the desktop call succeeded. Should a zero-count heap be refused, or accepted without memory? I left it untested; tell me which you want and I will add the case.

Verification

Commit 309cfede (main) plus this change, dev preset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0, WARP 10.0.26100.9818.

ctest --preset dev --no-tests=error -R '^startup_title_heap(_tags_control|_device_warp)?$' -V
#   3/3 passed (the tags control fails with 3 FAILs, as WILL_FAIL expects)

tests/docs_links_check.py, tests/bidi_controls_check.py and git diff --check passed.

Mutation probe

I applied each mutation to the header alone, rebuilt, and ran the following tests, then reverted. None of this is committed.

  • startup_title_heap
  • startup_title_heap_tags_control
  • startup_title_heap_device_warp
  • startup_null_views_warp
  • d3d12x_descriptor_{heap,table,negative}_warp
Mutant Existing With the new cases
control: drop the CBV_SRV_UAV clause killed killed
alignment mask alignof(int) - 1 killed killed
|| → && in the rule killed killed
ignore caller memory in the early return killed killed
every type except samplers needs memory killed killed
allocated address discarded survived killed
allocate(1) survived killed
allocate(bytes / 2) survived killed
drop the if (bytes) guard survived survived (zero-count question above)
return title_memory != 0 || !bytes survived survived (zero-count question above)

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6583351383 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1556). Originally posted by [Asimmimx](https://github.com/Asimmimx) on 2026-11-24T13:53:37Z. --- ## Change Refs #1149. This extends `startup_title_heap`, the check for `src/startup_stubs/title_heap_memory.h`. When a descriptor heap's desktop CPU start is not usable as an address (any CBV/SRV/UAV heap, or a heap whose start is tagged), the wrapper allocates plain memory of `NumDescriptors × increment` bytes. It gives that memory to the executable as the heap's CPU start. No existing test takes the path where this allocation succeeds: - `startup_title_heap` uses only an allocator that returns 0 and ignores the size it is asked for. - `startup_title_heap_device_warp` creates no view heap. On WARP the sampler, render-target and depth heaps have aligned starts. - `startup_view_heap_*` and `startup_null_views_*` pass memory of their own. - `d3d12x_descriptor_*_warp` get a plain desktop device. So three mutants left all of these passing: - discarding the allocated address, which would make every view heap created without its own memory fail with `E_OUTOFMEMORY`; - `allocate(1)`; - `allocate(bytes / 2)`. This adds four expectations to the existing `rule()`. An allocator that succeeds returns `0x20000` and records the size it is asked for. Two cases use hand-worked sizes: - an aligned view heap, 1024 × 32 = `0x8000` bytes; - a tagged sampler heap, 128 × 32 = `0x1000` bytes. Each call must return true, store `0x20000`, ask for exactly that size, and advance the allocation count to 2 and then 3. Only `tests/startup_title_heap_check.cpp` (+18 lines) and two sentences in the existing title-heap bullet of `docs/startup-runtime.md` change. There is no CMake change and no new CTest. The existing `startup_title_heap_tags_control` still fails as intended. **A behaviour I did not pin.** WARP's `CreateDescriptorHeap` accepts `NumDescriptors = 0` for all four heap types; I checked this with a scratch probe that is not committed. Such a heap is therefore reachable from the real caller. When it needs memory and has none of its own, `title_heap_memory` skips the allocation and returns false, so the wrapper returns `E_OUTOFMEMORY` although the desktop call succeeded. Should a zero-count heap be refused, or accepted without memory? I left it untested; tell me which you want and I will add the case. ## Verification Commit `309cfede` (`main`) plus this change, `dev` preset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0, WARP 10.0.26100.9818. ```powershell ctest --preset dev --no-tests=error -R '^startup_title_heap(_tags_control|_device_warp)?$' -V # 3/3 passed (the tags control fails with 3 FAILs, as WILL_FAIL expects) ``` `tests/docs_links_check.py`, `tests/bidi_controls_check.py` and `git diff --check` passed. ## Mutation probe I applied each mutation to the header alone, rebuilt, and ran the following tests, then reverted. None of this is committed. - `startup_title_heap` - `startup_title_heap_tags_control` - `startup_title_heap_device_warp` - `startup_null_views_warp` - `d3d12x_descriptor_{heap,table,negative}_warp` | Mutant | Existing | With the new cases | |---|---|---| | control: drop the `CBV_SRV_UAV` clause | killed | killed | | alignment mask `alignof(int) - 1` | killed | killed | | `\|\|` → `&&` in the rule | killed | killed | | ignore caller memory in the early return | killed | killed | | every type except samplers needs memory | killed | killed | | allocated address discarded | **survived** | killed | | `allocate(1)` | **survived** | killed | | `allocate(bytes / 2)` | **survived** | killed | | drop the `if (bytes)` guard | survived | survived (zero-count question above) | | `return title_memory != 0 \|\| !bytes` | survived | survived (zero-count question above) | ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-24 15:01:58 +00:00
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
R0Y00/Xbox2Windows!1549
No description provided.