startup: distinct DirectStorage error codes and null-argument checks #2178

Manually merged
github merged 7 commits from gh-pr/2178/head into gh-pr/2178/base 2026-11-27 00:03:13 +00:00
Owner

@⁠tedin7 on GitHub · 2026-11-25 02:59 UTC · original
tedin7:x2w-w4-1843-dstorage-status → main · +137 −48 · 14 files · 7 commits · merged 2026-11-25 04:33 UTC

Part of #1843

What this unblocks: a caller of the DirectStorage stand-in can tell a too-small destination from a read past the end of a file, and bad null arguments are refused instead of accepted silently.

Changes:

  • A destination smaller than the data reports 0x8007007A (ERROR_INSUFFICIENT_BUFFER); a file read at or past the end, or crossing it, reports 0x80070026 (ERROR_HANDLE_EOF). Other causes stay E_FAIL. The status entry and the first-failure record carry the same code.
  • OpenFile with a null path and CreateQueue with a null descriptor return E_INVALIDARG; a null output returns E_POINTER; the output is nulled on refusal.
  • Existing storage fixtures that expected E_FAIL for these causes now expect the specific code. startup_dstorage_destination_check gains positive and negative cases on the real stand-in DLL.
  • docs/startup-runtime.md documents the codes.

Verification:

  • python3 -B tests/docs_links_check.py -> PASS (18 files, 401 links), Linux.
  • python3 -B tests/run_checks_parallel_check.py -> PASS, Linux.
  • x86_64-w64-mingw32-g++ -std=c++17 -fsyntax-only on xcrdapi.cpp and the changed fixtures -> no errors apart from MSVC-only __try/__except in local_log.h.
  • Win2025 (Build 26100, MSVC 14.44.35207, D3D12 WARP) at 3cea0e4b, default 3-slot pool: python3 x2w_pipe.py win2025 2178 with the auto-discovered targets plus startup_storage_worker_start.
    • dev: ctest --preset dev 17/17 passed, 0 skipped.
    • release: ctest --preset release 17/17 passed, 0 skipped.
  • Also fixed in this PR: the archive directory fixtures pass a queue descriptor and expect 0x80070026 for the EOF case; Enqueue now catches a failed queue growth inside the lock scope so a std::bad_alloc no longer leaves the queue mutex held (startup_storage_worker_start, alloc sweep N=5, previously an exception left Submit).

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-25 02:59 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2178) `tedin7:x2w-w4-1843-dstorage-status` → `main` · +137 −48 · 14 files · 7 commits · merged 2026-11-25 04:33 UTC Part of #1843 What this unblocks: a caller of the DirectStorage stand-in can tell a too-small destination from a read past the end of a file, and bad null arguments are refused instead of accepted silently. Changes: - A destination smaller than the data reports `0x8007007A` (`ERROR_INSUFFICIENT_BUFFER`); a file read at or past the end, or crossing it, reports `0x80070026` (`ERROR_HANDLE_EOF`). Other causes stay `E_FAIL`. The status entry and the first-failure record carry the same code. - `OpenFile` with a null path and `CreateQueue` with a null descriptor return `E_INVALIDARG`; a null output returns `E_POINTER`; the output is nulled on refusal. - Existing storage fixtures that expected `E_FAIL` for these causes now expect the specific code. `startup_dstorage_destination_check` gains positive and negative cases on the real stand-in DLL. - `docs/startup-runtime.md` documents the codes. Verification: - `python3 -B tests/docs_links_check.py` -> PASS (18 files, 401 links), Linux. - `python3 -B tests/run_checks_parallel_check.py` -> PASS, Linux. - `x86_64-w64-mingw32-g++ -std=c++17 -fsyntax-only` on `xcrdapi.cpp` and the changed fixtures -> no errors apart from MSVC-only `__try/__except` in `local_log.h`. - Win2025 (Build 26100, MSVC 14.44.35207, D3D12 WARP) at `3cea0e4b`, default 3-slot pool: `python3 x2w_pipe.py win2025 2178` with the auto-discovered targets plus `startup_storage_worker_start`. - dev: `ctest --preset dev` 17/17 passed, 0 skipped. - release: `ctest --preset release` 17/17 passed, 0 skipped. - Also fixed in this PR: the archive directory fixtures pass a queue descriptor and expect `0x80070026` for the EOF case; `Enqueue` now catches a failed queue growth inside the lock scope so a `std::bad_alloc` no longer leaves the queue mutex held (`startup_storage_worker_start`, alloc sweep N=5, previously `an exception left Submit`). AI-assisted; commands listed were executed locally.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:03:11 +00:00
github manually merged commit 4ebbf8aa79 into gh-pr/2178/base 2026-11-27 00:03:13 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-25 03:59 UTC · original · edited 2026-11-25 04:05 UTC

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-25T04:05:06.494085Z 3cea0e4 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.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-25 03:59 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2178#issuecomment-7152425445) · edited 2026-11-25 04:05 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"3cea0e4bbcb9742f5cd6b8969e3eb22d919bea39","has_any_findings":true,"has_unresolved_findings":true,"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-25T04:05:06.494085Z">2026-11-25T04:05:06.494085Z</relative-time> | `3cea0e4` | 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>
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-25 04:05 UTC · original

P2 Badge Size the new queue descriptors for the factory's 40-byte read

Every begin_batch() call now passes this 32-byte array to factory_create_queue, but that function unconditionally reads 40 bytes from each non-null descriptor in src/startup_stubs/xcrdapi.cpp:355-357. Queue creation therefore reads eight bytes past the stack buffer; an ASan probe using the same logging loop reproduces a stack-buffer-overflow. Allocate at least 0x28 bytes here and for the newly added descriptor in dstorage_directory_batches() so the archive fixtures do not introduce an out-of-bounds read.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-25 04:05 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2178#discussion_r4690253109) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Size the new queue descriptors for the factory's 40-byte read** Every `begin_batch()` call now passes this 32-byte array to `factory_create_queue`, but that function unconditionally reads 40 bytes from each non-null descriptor in `src/startup_stubs/xcrdapi.cpp:355-357`. Queue creation therefore reads eight bytes past the stack buffer; an ASan probe using the same logging loop reproduces a stack-buffer-overflow. Allocate at least `0x28` bytes here and for the newly added descriptor in `dstorage_directory_batches()` so the archive fixtures do not introduce an out-of-bounds read. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 04:20 UTC · original

Fixed in 4ebbf8aa: every queue descriptor passed to factory slot 10 is now 0x28 bytes (directory_gpu.cpp and the other startup storage/dstorage fixtures that used 0x20), so the factory's 40-byte read stays in bounds.

Verification (Win2025, 3-slot pool, x2w_pipe.py win2025 2178 --force): dev 17/17 passed, release 17/17 passed, 0 skipped. Linux: python3 tests/docs_links_check.py passed.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-25 04:20 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2178#discussion_r4690347568) Fixed in 4ebbf8aa: every queue descriptor passed to factory slot 10 is now 0x28 bytes (directory_gpu.cpp and the other startup storage/dstorage fixtures that used 0x20), so the factory's 40-byte read stays in bounds. Verification (Win2025, 3-slot pool, `x2w_pipe.py win2025 2178 --force`): dev 17/17 passed, release 17/17 passed, 0 skipped. Linux: `python3 tests/docs_links_check.py` passed. AI-assisted; commands listed were executed locally.
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-25 04:05 UTC · original · reviewed

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3cea0e4bbc

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback".

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-25 04:05 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2178#pullrequestreview-6051702736) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `3cea0e4bbc` <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". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback". </details>
This discussion has been locked. Commenting is limited to contributors.
No description provided.