test: refuse a null layout destination #1741

Merged
ChazY11 merged 1 commit from upstream-pr/1748 into main 2026-11-24 18:27:20 +00:00
ChazY11 commented 2026-11-24 18:06:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T18:06:04Z.


What

computer_layout in src/startup_stubs/xg_xs.cpp starts with a null check:

if (!layout) return static_cast<long>(0x80004003);   // E_POINTER

tests/startup_xg_bc7_layout_check.py only ever passed a guarded buffer, so removing that check leaves it green:

null check replaced with `if (false)`    startup_xg_bc7_layout PASSED    (before this change)

Change

One query with no destination, expecting E_POINTER:

+        # A null destination is refused with E_POINTER before anything is written.
+        expect("GetResourceLayout(null) HRESULT", LAYOUT(vtable[2])(computer, None) & 0xFFFFFFFF, 0x80004003)

The & 0xFFFFFFFF is not cosmetic: ctypes hands the HRESULT back as a signed Python int (-2147467261), and the rest of
the file already masks before comparing. Without it the new line reports a spurious mismatch.

Tested at origin/main = 68969ed8

ctest --preset dev --no-tests=error -R '^startup_xg_bc7_' -V
with the case, check intact        startup_xg_bc7_layout PASSED (three shapes, refusal controls included)
with the case, null check removed  startup_xg_bc7_layout FAILED   (xg_xs.dll rebuilt, timestamp checked)
reverted, rebuilt                  all startup_xg_bc7_* PASSED

Scope

One test file, no behaviour change. The other two branches in this function that the fixture does not reach — the
max_mips clamp and the ~0ull / 0 slice-size fallback — I left alone; the clamp would need a descriptor with more mips
than a fixture currently builds, and the fallback needs a device answer of "no size", which the desktop path does not
produce. I would rather not guess at either.

Notes

  • AI-assisted.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6588272272 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1748). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T18:06:04Z. --- ## What `computer_layout` in `src/startup_stubs/xg_xs.cpp` starts with a null check: ```cpp if (!layout) return static_cast<long>(0x80004003); // E_POINTER ``` `tests/startup_xg_bc7_layout_check.py` only ever passed a guarded buffer, so removing that check leaves it green: ```text null check replaced with `if (false)` startup_xg_bc7_layout PASSED (before this change) ``` ## Change One query with no destination, expecting `E_POINTER`: ```diff + # A null destination is refused with E_POINTER before anything is written. + expect("GetResourceLayout(null) HRESULT", LAYOUT(vtable[2])(computer, None) & 0xFFFFFFFF, 0x80004003) ``` The `& 0xFFFFFFFF` is not cosmetic: ctypes hands the HRESULT back as a signed Python int (`-2147467261`), and the rest of the file already masks before comparing. Without it the new line reports a spurious mismatch. ## Tested at `origin/main` = `68969ed8` ```powershell ctest --preset dev --no-tests=error -R '^startup_xg_bc7_' -V ``` ```text with the case, check intact startup_xg_bc7_layout PASSED (three shapes, refusal controls included) with the case, null check removed startup_xg_bc7_layout FAILED (xg_xs.dll rebuilt, timestamp checked) reverted, rebuilt all startup_xg_bc7_* PASSED ``` ## Scope One test file, no behaviour change. The other two branches in this function that the fixture does not reach — the `max_mips` clamp and the `~0ull / 0` slice-size fallback — I left alone; the clamp would need a descriptor with more mips than a fixture currently builds, and the fallback needs a device answer of "no size", which the desktop path does not produce. I would rather not guess at either. ## Notes - AI-assisted.
upstream-sync closed this pull request 2026-11-24 19:01:17 +00:00
tedin7 commented 2026-11-24 19:01:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T18:26:32Z.

Review: COMMENTED


Verified at commit 11f3bb65a30adca55787299be95e8f8af8ae263a (tests/startup_xg_bc7_layout_check.py only; no production/tooling/workflow changes; clean-room and title-neutral).

Scope & Code Review

  • Adds a null-destination check in check_layout calling GetResourceLayout(None) (vtable[2]) and asserting E_POINTER (0x80004003).
  • Matches the if (!layout) return static_cast<long>(0x80004003); guard in computer_layout (src/startup_stubs/xg_xs.cpp:156).
  • No defects found (0 P1, 0 P2).

Linux Checks

  • git diff --check origin/main...HEAD: pass
  • python3 tests/docs_links_check.py: pass
  • python3 tests/bidi_controls_check.py: pass
  • python3 -m py_compile tests/startup_xg_bc7_layout_check.py: pass

Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)

  • Debug (--preset dev):
    • cmake --build --preset dev --target startup_stream_consumer startup_stub_xg_xs -- -j 8: pass (3.87s)
    • ctest --preset dev -R '^(startup_xg_bc7_layout|startup_xg_bc_array_warp|startup_xg_bc_chain_warp|startup_xg_bc_tiling|startup_xg_tile64_tiling)$' --parallel 6 --no-tests=error --output-on-failure: 5/5 passed (7.23s; startup_xg_bc7_layout 0.15s)
  • Release /O2 (--preset release):
    • cmake --build --preset release --target startup_stream_consumer startup_stub_xg_xs -- -j 8: pass (1.13s)
    • ctest --preset release -R '^(startup_xg_bc7_layout|startup_xg_bc_array_warp|startup_xg_bc_chain_warp|startup_xg_bc_tiling|startup_xg_tile64_tiling)$' --parallel 6 --no-tests=error --output-on-failure: 5/5 passed (7.72s; startup_xg_bc7_layout 0.14s)

Mutation Check (Win2025 Debug)

  • Mutated src/startup_stubs/xg_xs.cpp:156 in computer_layout from if (!layout) return static_cast<long>(0x80004003); to if (!layout) return static_cast<long>(0x80070057);.
  • Re-ran startup_xg_bc7_layout (ctest --preset dev -R '^startup_xg_bc7_layout$' --output-on-failure): failed as expected (RuntimeError: GetResourceLayout(null) HRESULT: got 2147942487, expected 2147500035).

Note: Competing open PRs (#1742, #1746) also modify tests/startup_xg_bc7_layout_check.py.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6045023191 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1748#pullrequestreview-6045023191). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T18:26:32Z. **Review:** COMMENTED --- Verified at commit `11f3bb65a30adca55787299be95e8f8af8ae263a` (`tests/startup_xg_bc7_layout_check.py` only; no production/tooling/workflow changes; clean-room and title-neutral). ### Scope & Code Review - Adds a null-destination check in `check_layout` calling `GetResourceLayout(None)` (`vtable[2]`) and asserting `E_POINTER` (`0x80004003`). - Matches the `if (!layout) return static_cast<long>(0x80004003);` guard in `computer_layout` (`src/startup_stubs/xg_xs.cpp:156`). - No defects found (0 P1, 0 P2). ### Linux Checks - `git diff --check origin/main...HEAD`: pass - `python3 tests/docs_links_check.py`: pass - `python3 tests/bidi_controls_check.py`: pass - `python3 -m py_compile tests/startup_xg_bc7_layout_check.py`: pass ### Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) - **Debug (`--preset dev`)**: - `cmake --build --preset dev --target startup_stream_consumer startup_stub_xg_xs -- -j 8`: pass (`3.87s`) - `ctest --preset dev -R '^(startup_xg_bc7_layout|startup_xg_bc_array_warp|startup_xg_bc_chain_warp|startup_xg_bc_tiling|startup_xg_tile64_tiling)$' --parallel 6 --no-tests=error --output-on-failure`: **5/5 passed** (`7.23s`; `startup_xg_bc7_layout` `0.15s`) - **Release `/O2` (`--preset release`)**: - `cmake --build --preset release --target startup_stream_consumer startup_stub_xg_xs -- -j 8`: pass (`1.13s`) - `ctest --preset release -R '^(startup_xg_bc7_layout|startup_xg_bc_array_warp|startup_xg_bc_chain_warp|startup_xg_bc_tiling|startup_xg_tile64_tiling)$' --parallel 6 --no-tests=error --output-on-failure`: **5/5 passed** (`7.72s`; `startup_xg_bc7_layout` `0.14s`) ### Mutation Check (Win2025 Debug) - Mutated `src/startup_stubs/xg_xs.cpp:156` in `computer_layout` from `if (!layout) return static_cast<long>(0x80004003);` to `if (!layout) return static_cast<long>(0x80070057);`. - Re-ran `startup_xg_bc7_layout` (`ctest --preset dev -R '^startup_xg_bc7_layout$' --output-on-failure`): **failed as expected** (`RuntimeError: GetResourceLayout(null) HRESULT: got 2147942487, expected 2147500035`). Note: Competing open PRs (#1742, #1746) also modify `tests/startup_xg_bc7_layout_check.py`. AI-assisted; commands listed were executed locally.
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!1741
No description provided.