acphal: roll back partial shape-context allocations and expand tests #1503

Merged
tedin7 merged 3 commits from upstream-pr/1510 into main 2026-11-24 14:30:38 +00:00
tedin7 commented 2026-11-24 13:22:56 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T13:22:56Z.


Summary

  • Fix AcpHalAllocateShapeContexts in src/startup_stubs/acphal.cpp to roll back any allocated XMA shape-context block via heap_give and zero arrays[4] / apu[4] on partial failure (e.g., when counts[4] != 0 succeeds and a later index such as counts[5] != 0 returns E_NOTIMPL).
  • Validate output block writability (x2w_local::writable) in AcpHalAllocateShapeContexts and AcpHalCreate, and guard 32-bit APU address conversion against overflow.
  • Extend tests/startup_acphal_apu_free.cpp with positive and negative-control checks for AcpHalAllocateShapeContexts (happy path, partial-failure rollback proving the APU heap block is returned and reusable, early E_NOTIMPL, null/read-only/OOM), AcpHalCreate (null/read-only and stand-in vtable calls), ApuIsVirtualAddressValid, ApuMapApuAddress, ApuMapVirtualAddress (including heap boundary negative controls), and non-permissive default traps (including AcpHalReleaseShapeContexts).
  • Update docs/startup-runtime.md to document the rollback and expanded test coverage.

Verification

  • git diff --check origin/main...HEAD
  • python3 -B tests/docs_links_check.py
  • python3 -B tests/bidi_controls_check.py
  • ctest --preset dev --no-tests=error -R '^(startup_acphal_apu_free|startup_stubs)$' -V
  • ctest --preset release --no-tests=error -R '^(startup_acphal_apu_free|startup_stubs)$' -V

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6582761264 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1510). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T13:22:56Z. --- ## Summary - Fix `AcpHalAllocateShapeContexts` in `src/startup_stubs/acphal.cpp` to roll back any allocated XMA shape-context block via `heap_give` and zero `arrays[4]` / `apu[4]` on partial failure (e.g., when `counts[4] != 0` succeeds and a later index such as `counts[5] != 0` returns `E_NOTIMPL`). - Validate output block writability (`x2w_local::writable`) in `AcpHalAllocateShapeContexts` and `AcpHalCreate`, and guard 32-bit APU address conversion against overflow. - Extend `tests/startup_acphal_apu_free.cpp` with positive and negative-control checks for `AcpHalAllocateShapeContexts` (happy path, partial-failure rollback proving the APU heap block is returned and reusable, early `E_NOTIMPL`, null/read-only/OOM), `AcpHalCreate` (null/read-only and stand-in vtable calls), `ApuIsVirtualAddressValid`, `ApuMapApuAddress`, `ApuMapVirtualAddress` (including heap boundary negative controls), and non-permissive default traps (including `AcpHalReleaseShapeContexts`). - Update `docs/startup-runtime.md` to document the rollback and expanded test coverage. ## Verification - `git diff --check origin/main...HEAD` - `python3 -B tests/docs_links_check.py` - `python3 -B tests/bidi_controls_check.py` - `ctest --preset dev --no-tests=error -R '^(startup_acphal_apu_free|startup_stubs)$' -V` - `ctest --preset release --no-tests=error -R '^(startup_acphal_apu_free|startup_stubs)$' -V` AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-24 14:03:25 +00:00 (Migrated from github.com)

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


Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 0103dd53939814542ba80a4d2a2c76f3a87272d9:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target d3d12_xs_shim startup_acphal_apu_free startup_stub_acphal startup_stub_chad startup_stub_consumer startup_stub_gameinput startup_stub_xapu startup_stub_xcrdapi startup_stub_xg_xs xmem_shim -- -j 6): 3.99s (configure 1.79s)
    • Test (ctest --preset dev -R '^(startup_acphal_apu_free|startup_stubs)$' --parallel 4 --no-tests=error --output-on-failure): 2/2 passed (0.55s: startup_acphal_apu_free 0.22s, startup_stubs 0.48s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target d3d12_xs_shim startup_acphal_apu_free startup_stub_acphal startup_stub_chad startup_stub_consumer startup_stub_gameinput startup_stub_xapu startup_stub_xcrdapi startup_stub_xg_xs xmem_shim -- -j 6): 1.79s (configure 1.94s)
    • Test (ctest --preset release -R '^(startup_acphal_apu_free|startup_stubs)$' --parallel 4 --no-tests=error --output-on-failure): 2/2 passed (0.60s: startup_acphal_apu_free 0.10s, startup_stubs 0.52s)
  • sccache: 9/11 hits; wall 17.1s

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7133100465 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1510#issuecomment-7133100465). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T13:37:35Z. --- Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `0103dd53939814542ba80a4d2a2c76f3a87272d9`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target d3d12_xs_shim startup_acphal_apu_free startup_stub_acphal startup_stub_chad startup_stub_consumer startup_stub_gameinput startup_stub_xapu startup_stub_xcrdapi startup_stub_xg_xs xmem_shim -- -j 6`): `3.99s` (configure `1.79s`) - Test (`ctest --preset dev -R '^(startup_acphal_apu_free|startup_stubs)$' --parallel 4 --no-tests=error --output-on-failure`): **2/2 passed** (`0.55s`: `startup_acphal_apu_free` `0.22s`, `startup_stubs` `0.48s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target d3d12_xs_shim startup_acphal_apu_free startup_stub_acphal startup_stub_chad startup_stub_consumer startup_stub_gameinput startup_stub_xapu startup_stub_xcrdapi startup_stub_xg_xs xmem_shim -- -j 6`): `1.79s` (configure `1.94s`) - Test (`ctest --preset release -R '^(startup_acphal_apu_free|startup_stubs)$' --parallel 4 --no-tests=error --output-on-failure`): **2/2 passed** (`0.60s`: `startup_acphal_apu_free` `0.10s`, `startup_stubs` `0.52s`) - `sccache`: 9/11 hits; wall `17.1s` AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-24 14:03:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T13:37:47Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T13:41:13.347826Z 0103dd5 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7133105535 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1510#issuecomment-7133105535). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T13:37:47Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"0103dd53939814542ba80a4d2a2c76f3a87272d9","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T13:41:13.347826Z">2026-11-24T13:41:13.347826Z</relative-time> | `0103dd5` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
upstream-sync closed this pull request 2026-11-24 15:01:48 +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!1503
No description provided.