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

Closed
Taffyyy-ops wants to merge 1 commit from upstream-pr/1134 into main
Taffyyy-ops commented 2026-11-24 19:06:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Taffyyy-ops on 2026-11-24T19:06:34Z.


Item ID: RT-XS-FRAME-STATS-NULL-COUNT (#14 claim: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7141449898)

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.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5478557825 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1134). Originally posted by [Taffyyy-ops](https://github.com/Taffyyy-ops) on 2026-11-24T19:06:34Z. --- Item ID: `RT-XS-FRAME-STATS-NULL-COUNT` (#14 claim: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7141449898) ### 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.
abnalstlll-byte commented 2026-11-24 19:14:53 +00:00 (Migrated from github.com)

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

Review: APPROVED


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045720568 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1134#pullrequestreview-6045720568). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T19:14:53Z. **Review:** APPROVED --- 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.
madhyn commented 2026-11-24 19:32:00 +00:00 (Migrated from github.com)

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


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7142233254 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1134#issuecomment-7142233254). Originally posted by [madhyn](https://github.com/madhyn) on 2026-11-24T19:32:00Z. --- 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
Deedlyy commented 2026-11-24 20:14:38 +00:00 (Migrated from github.com)

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


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7143241951 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1134#issuecomment-7143241951). Originally posted by [Deedlyy](https://github.com/Deedlyy) on 2026-11-24T20:14:38Z. --- **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
Taffyyy-ops commented 2026-11-25 10:45:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Taffyyy-ops on 2026-11-25T10:45:25Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7160130388 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1134#issuecomment-7160130388). Originally posted by [Taffyyy-ops](https://github.com/Taffyyy-ops) on 2026-11-25T10:45:25Z. --- @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 commented 2026-11-25 12:07:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Taffyyy-ops on 2026-11-25T12:07:12Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7161944076 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1134#issuecomment-7161944076). Originally posted by [Taffyyy-ops](https://github.com/Taffyyy-ops) on 2026-11-25T12:07:12Z. --- 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

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!1134
No description provided.