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

Merged
tedin7 merged 7 commits from upstream-pr/2178 into main 2026-11-25 04:33:17 +00:00
tedin7 commented 2026-11-25 02:59:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:59:50Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6596184831 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2178). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:59:50Z. --- 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.
chatgpt-codex-connector[bot commented 2026-11-25 04:04:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T03:59:24Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7152425445 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2178#issuecomment-7152425445). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T03:59:24Z. --- <!-- 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>
upstream-sync closed this pull request 2026-11-25 05:04:45 +00:00
chatgpt-codex-connector[bot commented 2026-11-25 05:04:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T04:05:03Z.

Review: COMMENTED


💡 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".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6051702736 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2178#pullrequestreview-6051702736). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T04:05:03Z. **Review:** COMMENTED --- <!-- 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>
tedin7 commented 2026-11-25 05:04:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T04:20:50Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6051811734 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2178#pullrequestreview-6051811734). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T04:20:50Z. **Review:** COMMENTED --- _No description provided._
chatgpt-codex-connector[bot commented 2026-11-25 05:04:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T04:05:03Z.

Code review location: tests/cpu/archive/directory_gpu.cpp; line 82

@@ -79,7 +79,8 @@ bool begin_batch()
     auto factory = static_cast<Ptr>(result);
     const GUID* iid = nullptr;
     const HRESULT file_result = invoke<4, HRESULT>(factory, archive_name, iid, &file);
-    const HRESULT queue_result = invoke<10, HRESULT>(factory, static_cast<const void*>(nullptr), iid, &queue);
+    const unsigned char queue_description[0x20] = {};

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 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4690253109 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2178#discussion_r4690253109). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T04:05:03Z. **Code review location:** `tests/cpu/archive/directory_gpu.cpp`; line 82 ~~~~diff @@ -79,7 +79,8 @@ bool begin_batch() auto factory = static_cast<Ptr>(result); const GUID* iid = nullptr; const HRESULT file_result = invoke<4, HRESULT>(factory, archive_name, iid, &file); - const HRESULT queue_result = invoke<10, HRESULT>(factory, static_cast<const void*>(nullptr), iid, &queue); + const unsigned char queue_description[0x20] = {}; ~~~~ --- **<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 -->
tedin7 commented 2026-11-25 05:04:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T04:20:50Z.

Code review location: tests/cpu/archive/directory_gpu.cpp; line 82

@@ -79,7 +79,8 @@ bool begin_batch()
     auto factory = static_cast<Ptr>(result);
     const GUID* iid = nullptr;
     const HRESULT file_result = invoke<4, HRESULT>(factory, archive_name, iid, &file);
-    const HRESULT queue_result = invoke<10, HRESULT>(factory, static_cast<const void*>(nullptr), iid, &queue);
+    const unsigned char queue_description[0x20] = {};

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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4690347568 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2178#discussion_r4690347568). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T04:20:50Z. **Code review location:** `tests/cpu/archive/directory_gpu.cpp`; line 82 ~~~~diff @@ -79,7 +79,8 @@ bool begin_batch() auto factory = static_cast<Ptr>(result); const GUID* iid = nullptr; const HRESULT file_result = invoke<4, HRESULT>(factory, archive_name, iid, &file); - const HRESULT queue_result = invoke<10, HRESULT>(factory, static_cast<const void*>(nullptr), iid, &queue); + const unsigned char queue_description[0x20] = {}; ~~~~ --- 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.
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!2170
No description provided.