d3d12_xs: validate pCount in detached GetFrameStatisticsX (RT-XS-FRAME-STATS-NULL-COUNT) #1134

Closed
github-bot wants to merge 1 commit from gh-pr/1134/head into gh-pr/1134/base
Owner

@⁠Taffyyy-ops on GitHub · 2026-11-24 19:06 UTC · original
Taffyyy-ops:fix/xs-frame-stats-null-count → main · +34 −6 · 2 files · 1 commits · closed without merging

Item ID: RT-XS-FRAME-STATS-NULL-COUNT (#14 claim: #14)

Summary

  • Align the detached GetFrameStatisticsX fallback (Slot == routes.frame_statistics, default device slot 81) in runtime/shims/d3d12_xs_device.cpp with FramePacer::get_frame_statistics (runtime/src/frame_pacer.h): when pCount (a3) is nullptr, return E_INVALIDARG instead of S_FALSE (without forwarding to PC slot 81 ID3D12Device13::OpenExistingHeapFromAddress1).
  • Keep returning S_FALSE and zeroing *pCount when pCount != nullptr (including when pStats / a4 is nullptr), matching FramePacer::get_frame_statistics.
  • Left docs/d3d12_vulkan.md and docs/d3d12_xs_surface.md untouched (neither states unattached S_FALSE on null pCount, and leaving docs untouched avoids conflicting with #1125).
  • Updated runtime/test/xs_proxy_mock_test.cpp (run_env_slots invalid-env case and check_presentation_wiring) with synthetic regression tests covering detached and partial-handler (get_frame_statistics == nullptr) calls with null/non-null pCount and sentinel out buffers, verifying mock->calls[81] == 0.

Testing & Verification

AI-assisted: yes (no game files, LEONIDA_GAME_DIR and LEONIDA_MOVIE unset).
Environment: Windows 11, MSVC 19.44 + Ninja, NVIDIA GeForce RTX 5060 Laptop GPU (driver 621.24), WARP.

  • Build: cmake --build runtime/build -> 0 errors, 0 new /W4 warnings on d3d12_xs_device.cpp or xs_proxy_mock_test.cpp.
  • CTest (ctest --test-dir runtime/build --output-on-failure -R "^(xs_proxy_mock|device_proxy|frame_pacer|xbox_present)"): 11/11 passed (xbox_present_readback_size, device_proxy, device_proxy_trace, xs_proxy_mock, xs_proxy_mock_no_reserve, xs_proxy_mock_no_protect, xs_proxy_mock_no_handler, xs_proxy_mock_env_slots, xs_proxy_mock_env_slots_invalid, xbox_present on NVIDIA GeForce RTX 5060 Laptop GPU, frame_pacer).
  • python -I tests/test_ctest_registration.py: 4/4 OK.
  • python -I scripts/check_no_game_data.py runtime/shims/d3d12_xs_device.cpp runtime/test/xs_proxy_mock_test.cpp: exited 0.
  • git diff --check: clean.
**@⁠Taffyyy-ops** on GitHub · 2026-11-24 19:06 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1134) `Taffyyy-ops:fix/xs-frame-stats-null-count` → `main` · +34 −6 · 2 files · 1 commits · closed without merging Item ID: `RT-XS-FRAME-STATS-NULL-COUNT` (#14 claim: https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### Summary - Align the detached `GetFrameStatisticsX` fallback (`Slot == routes.frame_statistics`, default device slot `81`) in `runtime/shims/d3d12_xs_device.cpp` with `FramePacer::get_frame_statistics` (`runtime/src/frame_pacer.h`): when `pCount` (`a3`) is `nullptr`, return `E_INVALIDARG` instead of `S_FALSE` (without forwarding to PC slot 81 `ID3D12Device13::OpenExistingHeapFromAddress1`). - Keep returning `S_FALSE` and zeroing `*pCount` when `pCount != nullptr` (including when `pStats` / `a4` is `nullptr`), matching `FramePacer::get_frame_statistics`. - Left `docs/d3d12_vulkan.md` and `docs/d3d12_xs_surface.md` untouched (neither states unattached `S_FALSE` on null `pCount`, and leaving docs untouched avoids conflicting with #1125). - Updated `runtime/test/xs_proxy_mock_test.cpp` (`run_env_slots` invalid-env case and `check_presentation_wiring`) with synthetic regression tests covering detached and partial-handler (`get_frame_statistics == nullptr`) calls with null/non-null `pCount` and sentinel `out` buffers, verifying `mock->calls[81] == 0`. ### Testing & Verification AI-assisted: yes (no game files, `LEONIDA_GAME_DIR` and `LEONIDA_MOVIE` unset). Environment: Windows 11, MSVC 19.44 + Ninja, NVIDIA GeForce RTX 5060 Laptop GPU (driver `621.24`), WARP. - Build: `cmake --build runtime/build` -> 0 errors, 0 new `/W4` warnings on `d3d12_xs_device.cpp` or `xs_proxy_mock_test.cpp`. - CTest (`ctest --test-dir runtime/build --output-on-failure -R "^(xs_proxy_mock|device_proxy|frame_pacer|xbox_present)"`): **11/11 passed** (`xbox_present_readback_size`, `device_proxy`, `device_proxy_trace`, `xs_proxy_mock`, `xs_proxy_mock_no_reserve`, `xs_proxy_mock_no_protect`, `xs_proxy_mock_no_handler`, `xs_proxy_mock_env_slots`, `xs_proxy_mock_env_slots_invalid`, `xbox_present` on `NVIDIA GeForce RTX 5060 Laptop GPU`, `frame_pacer`). - `python -I tests/test_ctest_registration.py`: 4/4 OK. - `python -I scripts/check_no_game_data.py runtime/shims/d3d12_xs_device.cpp runtime/test/xs_proxy_mock_test.cpp`: exited 0. - `git diff --check`: clean.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:39:48 +00:00
github-bot closed this pull request 2026-11-26 09:39:48 +00:00
Author
Owner

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

Reviewed and verified. Aligns detached GetFrameStatisticsX fallback (device slot 81) in runtime/shims/d3d12_xs_device.cpp with FramePacer by returning E_INVALIDARG when pCount is nullptr, and S_FALSE with *pCount = 0 when provided. Verified via synthetic mock device suites in runtime/test/xs_proxy_mock_test.cpp (11/11 CTests PASS). 100% clean-room.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 19:14 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1134#pullrequestreview-6045720568) · **approved these changes** Reviewed and verified. Aligns detached `GetFrameStatisticsX` fallback (device slot 81) in `runtime/shims/d3d12_xs_device.cpp` with `FramePacer` by returning `E_INVALIDARG` when `pCount` is `nullptr`, and `S_FALSE` with `*pCount = 0` when provided. Verified via synthetic mock device suites in `runtime/test/xs_proxy_mock_test.cpp` (11/11 CTests PASS). 100% clean-room.
Author
Owner

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

Tested 97c980703 on Arch Linux + Wine 11.22 (clang-cl + xwin cross-build):

  • ctest --test-dir runtime/build/win -R "^xs_proxy_mock" --output-on-failure: 6/6 passed (31.90 s)

AI-assisted: yes

**@⁠madhyn** on GitHub · 2026-11-24 19:32 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1134#issuecomment-7142233254) Tested `97c980703` on Arch Linux + Wine 11.22 (clang-cl + xwin cross-build): - `ctest --test-dir runtime/build/win -R "^xs_proxy_mock" --output-on-failure`: **6/6 passed** (31.90 s) AI-assisted: yes
Author
Owner

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

Recommendation: [MERGE]

Reasoning: The detached GetFrameStatisticsX fallback returns E_INVALIDARG for a null pCount, matching FramePacer::get_frame_statistics, instead of S_FALSE. Small, consistent fix with a mock test. Verified on Wine by madhyn (6/6). 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: 3/10

**@⁠Deedlyy** on GitHub · 2026-11-24 20:14 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1134#issuecomment-7143241951) **Recommendation:** [MERGE] **Reasoning:** The detached `GetFrameStatisticsX` fallback returns `E_INVALIDARG` for a null `pCount`, matching `FramePacer::get_frame_statistics`, instead of `S_FALSE`. Small, consistent fix with a mock test. Verified on Wine by madhyn (6/6). 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:** 3/10
Author
Owner

@⁠Taffyyy-ops on GitHub · 2026-11-25 10:45 UTC · original

@⁠abnalstlll-byte @⁠madhyn @⁠Deedlyy Thanks for the review, the Arch Linux + Wine 11.22 test run (6/6), and the [MERGE] recommendation! Checking current upstream/main (273b3bdf9 / RT-PROTON-STORY-LOAD), detached GetFrameStatisticsX (slot 81) in runtime/shims/d3d12_xs_device.cpp (L4473-L4492) and runtime/test/xs_proxy_mock_test.cpp (L2156-L2164, L4036-L4042) already added null-pCount / missing-buffer validation (E_POINTER) alongside retail-measured S_OK. Because main already covers the null-pointer guard with retail-measured S_OK, #1134 appears superseded.

**@⁠Taffyyy-ops** on GitHub · 2026-11-25 10:45 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1134#issuecomment-7160130388) @⁠abnalstlll-byte @⁠madhyn @⁠Deedlyy Thanks for the review, the Arch Linux + Wine 11.22 test run (6/6), and the `[MERGE]` recommendation! Checking current `upstream/main` (`273b3bdf9` / `RT-PROTON-STORY-LOAD`), detached `GetFrameStatisticsX` (`slot 81`) in `runtime/shims/d3d12_xs_device.cpp` (`L4473-L4492`) and `runtime/test/xs_proxy_mock_test.cpp` (`L2156-L2164`, `L4036-L4042`) already added null-`pCount` / missing-buffer validation (`E_POINTER`) alongside retail-measured `S_OK`. Because `main` already covers the null-pointer guard with retail-measured `S_OK`, `#1134` appears superseded.
Author
Owner

@⁠Taffyyy-ops on GitHub · 2026-11-25 12:07 UTC · original

Closing as superseded by upstream/main (273b3bdf9: detached GetFrameStatisticsX already validates null pCount with E_POINTER and returns retail-measured S_OK).

**@⁠Taffyyy-ops** on GitHub · 2026-11-25 12:07 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1134#issuecomment-7161944076) Closing as superseded by upstream/main (273b3bdf9: detached GetFrameStatisticsX already validates null pCount with E_POINTER and returns retail-measured S_OK).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.