DirectStorage: report queue read failures #624

Closed
github-bot wants to merge 3 commits from gh-pr/624/head into gh-pr/624/base
Owner

@⁠broccolize on GitHub · 2026-11-24 05:48 UTC · original
broccolize:hle/dstorage-queue-error-reporting → main · +435 −47 · 2 files · 3 commits · closed without merging

Implement GetErrorEvent and RetrieveErrorRecord for DirectStorage queues. Each queue signals its own error event and gives callers a handle they can close independently. Retrieval returns the first failed read in enqueue order and the failure count since the previous retrieval, then clears the record and resets the event.

Synthetic Windows tests cover two failed reads, a successful read, out-of-order worker completion, and a status entry submitted after error retrieval. All 15 DirectStorage tests passed with and without diagnostics.

The Windows GNU workspace run passed 265 tests with four ignored. It excluded loads_binds_and_calls_probe because of a toolchain failure reproducible on main. Asset-policy checks passed.

Related to #577, which touches file lifetime in the same worker path. AI-assisted with Codex.

**@⁠broccolize** on GitHub · 2026-11-24 05:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/624) `broccolize:hle/dstorage-queue-error-reporting` → `main` · +435 −47 · 2 files · 3 commits · closed without merging Implement `GetErrorEvent` and `RetrieveErrorRecord` for DirectStorage queues. Each queue signals its own error event and gives callers a handle they can close independently. Retrieval returns the first failed read in enqueue order and the failure count since the previous retrieval, then clears the record and resets the event. Synthetic Windows tests cover two failed reads, a successful read, out-of-order worker completion, and a status entry submitted after error retrieval. All 15 DirectStorage tests passed with and without diagnostics. The Windows GNU workspace run passed 265 tests with four ignored. It excluded `loads_binds_and_calls_probe` because of a toolchain failure reproducible on `main`. Asset-policy checks passed. Related to #577, which touches file lifetime in the same worker path. AI-assisted with Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:10:29 +00:00
github-bot closed this pull request 2026-11-26 04:10:29 +00:00
Author
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 12:19 UTC · original

Independent verification & code review on Windows 11 x64 MSVC (merged onto main ffe310e):

Checks Run

  • cargo xtask policy: PASS (155 files ok)
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings (default + --features diagnostics): PASS (0 warnings)
  • cargo test -p victory-hle --locked -- dstorage: PASS (15/15 tests, including queue_reports_and_retrieves_read_errors and error_event_reports_failures_in_enqueue_order_without_status_entries)

Review Findings

The ABI layout assertions for ErrorRecord (0x290) and ReadFailure, enqueue-ordered publish_before deferral, caller-owned duplicated event handles, and out.is_null() guards look very clean.

One safety edge case to tighten before merge:

  1. ReadFailure::new dereferences request.source as Instance<File> on unsupported-option failures (crates/victory-hle/src/modules/dstorage/errors.rs:92-102):
    • execute() rejects unsupported option bits with E_NOTIMPL before touching request.source (dstorage.rs:843) — including bit 23 (physical-pages source, documented at dstorage.rs:691), where request.source points to a page-number array rather than an Instance<File> COM object.
    • Because work() immediately calls ReadFailure::new(&job.request, hr) on that Err(E_NOTIMPL), and ReadFailure::new checks only request.options & MEMORY_SOURCE != 0, a bit-23 request enters the else branch and casts request.source to &Instance<File> to copy file.state.filename (Box<[u16]>), which is UB / an access violation on a non-File pointer.
    • Fix: Only treat request.source as Instance<File> when no unsupported option bits are set (or at minimum when bit 23 is clear) in addition to request.options & MEMORY_SOURCE == 0.
  2. (Minor semantic note) QueueErrors::new creates an auto-reset event (bManualReset = 0), while take() also calls ResetEvent. If a title polls WaitForSingleObject(event, 0) more than once before calling RetrieveErrorRecord (or duplicates the handle across watchers), auto-reset consumes the signal on the first wait; a manual-reset event (bManualReset = 1) stays signaled until RetrieveErrorRecord resets it (if matching the Win32 DirectStorage contract is preferred).

AI-assisted; synthetic tests only, no game files.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 12:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/624#issuecomment-7131279841) Independent verification & code review on Windows 11 x64 MSVC (merged onto `main` `ffe310e`): ### Checks Run - `cargo xtask policy`: **PASS** (`155 files ok`) - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings` (default + `--features diagnostics`): **PASS** (0 warnings) - `cargo test -p victory-hle --locked -- dstorage`: **PASS** (`15/15` tests, including `queue_reports_and_retrieves_read_errors` and `error_event_reports_failures_in_enqueue_order_without_status_entries`) ### Review Findings The ABI layout assertions for `ErrorRecord` (`0x290`) and `ReadFailure`, enqueue-ordered `publish_before` deferral, caller-owned duplicated event handles, and `out.is_null()` guards look very clean. One safety edge case to tighten before merge: 1. **`ReadFailure::new` dereferences `request.source` as `Instance<File>` on unsupported-option failures (`crates/victory-hle/src/modules/dstorage/errors.rs:92-102`)**: - `execute()` rejects unsupported option bits with `E_NOTIMPL` before touching `request.source` (`dstorage.rs:843`) — including **bit 23** (physical-pages source, documented at `dstorage.rs:691`), where `request.source` points to a page-number array rather than an `Instance<File>` COM object. - Because `work()` immediately calls `ReadFailure::new(&job.request, hr)` on that `Err(E_NOTIMPL)`, and `ReadFailure::new` checks only `request.options & MEMORY_SOURCE != 0`, a bit-23 request enters the `else` branch and casts `request.source` to `&Instance<File>` to copy `file.state.filename` (`Box<[u16]>`), which is UB / an access violation on a non-`File` pointer. - **Fix**: Only treat `request.source` as `Instance<File>` when no unsupported option bits are set (or at minimum when bit 23 is clear) in addition to `request.options & MEMORY_SOURCE == 0`. 2. *(Minor semantic note)* `QueueErrors::new` creates an **auto-reset** event (`bManualReset = 0`), while `take()` also calls `ResetEvent`. If a title polls `WaitForSingleObject(event, 0)` more than once before calling `RetrieveErrorRecord` (or duplicates the handle across watchers), auto-reset consumes the signal on the first wait; a manual-reset event (`bManualReset = 1`) stays signaled until `RetrieveErrorRecord` resets it (if matching the Win32 DirectStorage contract is preferred). *AI-assisted; synthetic tests only, no game files.*
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:26 UTC · original

Automated triage for the maintainers. Closing because it breaks a repository rule (see docs/asset-policy.md and the project rules): nothing taken from the console SDK or the game, no weakening of the asset policy, and the title stays offline.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/624#issuecomment-7148510587) Automated triage for the maintainers. Closing because it breaks a repository rule (see `docs/asset-policy.md` and the project rules): nothing taken from the console SDK or the game, no weakening of the asset policy, and the title stays offline. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Author
Owner

@⁠broccolize on GitHub · 2026-11-25 03:43 UTC · original

Thanks for reviewing. The diff is limited to two Rust source files for DirectStorage error reporting and synthetic tests. I checked the ABI locally against Microsoft's public documentation and public Xbox compatibility sample. The verification probe was kept local.

Could you point me to the file or line that triggered the policy closure so I can address it?

**@⁠broccolize** on GitHub · 2026-11-25 03:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/624#issuecomment-7152189391) Thanks for reviewing. The diff is limited to two Rust source files for DirectStorage error reporting and synthetic tests. I checked the ABI locally against Microsoft's public documentation and public Xbox compatibility sample. The verification probe was kept local. Could you point me to the file or line that triggered the policy closure so I can address it?

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!624
No description provided.