startup: fail XDspActivate and XDspSubmitCommand instead of succeeding without outputs #1900

Merged
ChazY11 merged 2 commits from upstream-pr/1907 into main 2026-11-24 21:10:53 +00:00
ChazY11 commented 2026-11-24 20:46:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T20:46:43Z.


Implements the narrow failure-only slice R0Y00 asked for in #1887.

Problem

With X2W_AUDIO_PERMISSIVE=1, XDspActivate and XDspSubmitCommand returned 0 and wrote nothing. A caller that
gates its first submit on activation success then read the status pointer the stand-in never wrote — at +0xC, the offset
of result in the documented XDspStatus — and stopped with an access violation.

Change

src/startup_stubs/chad.cpp only:

  • XDspActivate(client, params, XDspStatus** status, XDspStreamHandle* stream) validates both output pointers, clears
    them, and returns XDSP_E_NO_DEVICE_RESOURCES (0x8AC810A2). E_POINTER when either output is null or unwritable.
  • XDspSubmitCommand(stream, command, uint32_t* sequence) refuses a null or unknown stream handle with E_INVALIDARG
    without writing the sequence, and a known handle still has no device, so the caller's sequence value survives every
    failure path.
  • XDspConnectWithMaximumStreamLimit is unchanged: it still returns S_OK and publishes the handle, so #1871's out-handle
    checks stand.
  • Nothing is trapped differently: the permissive gate and the x2w-audio logging are untouched.

The two codes are the GDK definitions (XDSP_E_NO_DEVICE_RESOURCES = 0x8AC810A2, next to XDSP_E_QUEUE_FULL =
0x8AC810A0), read from Microsoft's error code list
rather than assumed.

Tested

cmake --preset dev
cmake --build --preset dev --target startup_stub_chad startup_chad_check
ctest --preset dev --no-tests=error -R '^startup_chad' -V
100% tests passed, 0 tests failed out of 1

tests/startup_chad_check.cpp replaces the two placeholder-success assertions with:

case expected
XDspActivate(unwritable outputs) E_POINTER
XDspActivate(valid outputs) XDSP_E_NO_DEVICE_RESOURCES, both outputs null
XDspActivate(null status*) / (null stream*) E_POINTER each
XDspSubmitCommand(null handle) E_INVALIDARG, sequence still 0xdeadbeef
XDspSubmitCommand(unknown handle) E_INVALIDARG, sequence still 0xdeadbeef
XDspSubmitCommand(known handle) XDSP_E_NO_DEVICE_RESOURCES, sequence still 0xdeadbeef
synthetic caller that gates its first submit on activation success never submits (sequence == 0)

The last row is the acceptance case from #1887: it fails when the old successful-no-output behaviour is restored.

Negative controls

Each rebuilt into chad.dll (timestamp verified) and reverted:

mutation result
both exports back to return hr_ok; (the old behaviour) caught
*status_out = nullptr; dropped from XDspActivate caught
the unknown-handle refusal dropped from XDspSubmitCommand caught

One mutation I expected to be caught and was not: dropping the null check on status_out keeps the test green. That
one is equivalent rather than uncovered — x2w_local::accessible() rejects any address below 0x10000
(if (start < 0x10000 ... ) return false;), so writable(nullptr, ...) is already false and the explicit !status_out
is documentation. I kept it for intent and am saying so rather than pretending the guard is pinned.

Scope

src/startup_stubs/chad.cpp and tests/startup_chad_check.cpp. No docs change: docs/startup-runtime.md mentions
chad.dll only as a produced file, and the placeholder-success sentence it did carry is in the test, which this updates.
The real provider, XApu and audible XAudio2 output are untouched, as asked.

Notes

  • AI-assisted.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6591080906 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1907). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T20:46:43Z. --- Implements the narrow failure-only slice R0Y00 asked for in #1887. ## Problem With `X2W_AUDIO_PERMISSIVE=1`, `XDspActivate` and `XDspSubmitCommand` returned 0 and wrote nothing. A caller that gates its first submit on activation success then read the status pointer the stand-in never wrote — at `+0xC`, the offset of `result` in the documented `XDspStatus` — and stopped with an access violation. ## Change `src/startup_stubs/chad.cpp` only: - `XDspActivate(client, params, XDspStatus** status, XDspStreamHandle* stream)` validates both output pointers, clears them, and returns **`XDSP_E_NO_DEVICE_RESOURCES` (0x8AC810A2)**. `E_POINTER` when either output is null or unwritable. - `XDspSubmitCommand(stream, command, uint32_t* sequence)` refuses a null or unknown stream handle with `E_INVALIDARG` **without** writing the sequence, and a known handle still has no device, so the caller's sequence value survives every failure path. - `XDspConnectWithMaximumStreamLimit` is unchanged: it still returns S_OK and publishes the handle, so #1871's out-handle checks stand. - Nothing is trapped differently: the permissive gate and the `x2w-audio` logging are untouched. The two codes are the GDK definitions (`XDSP_E_NO_DEVICE_RESOURCES` = `0x8AC810A2`, next to `XDSP_E_QUEUE_FULL` = `0x8AC810A0`), read from [Microsoft's error code list](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/errorcodes?view=gdk-2604) rather than assumed. ## Tested ```powershell cmake --preset dev cmake --build --preset dev --target startup_stub_chad startup_chad_check ctest --preset dev --no-tests=error -R '^startup_chad' -V 100% tests passed, 0 tests failed out of 1 ``` `tests/startup_chad_check.cpp` replaces the two placeholder-success assertions with: | case | expected | |---|---| | `XDspActivate(unwritable outputs)` | `E_POINTER` | | `XDspActivate(valid outputs)` | `XDSP_E_NO_DEVICE_RESOURCES`, **both** outputs null | | `XDspActivate(null status*)` / `(null stream*)` | `E_POINTER` each | | `XDspSubmitCommand(null handle)` | `E_INVALIDARG`, sequence still `0xdeadbeef` | | `XDspSubmitCommand(unknown handle)` | `E_INVALIDARG`, sequence still `0xdeadbeef` | | `XDspSubmitCommand(known handle)` | `XDSP_E_NO_DEVICE_RESOURCES`, sequence still `0xdeadbeef` | | synthetic caller that gates its first submit on activation success | never submits (`sequence == 0`) | The last row is the acceptance case from #1887: it fails when the old successful-no-output behaviour is restored. ## Negative controls Each rebuilt into `chad.dll` (timestamp verified) and reverted: | mutation | result | |---|---| | both exports back to `return hr_ok;` (the old behaviour) | **caught** | | `*status_out = nullptr;` dropped from `XDspActivate` | **caught** | | the unknown-handle refusal dropped from `XDspSubmitCommand` | **caught** | One mutation I expected to be caught and was not: dropping the **null** check on `status_out` keeps the test green. That one is equivalent rather than uncovered — `x2w_local::accessible()` rejects any address below `0x10000` (`if (start < 0x10000 ... ) return false;`), so `writable(nullptr, ...)` is already false and the explicit `!status_out` is documentation. I kept it for intent and am saying so rather than pretending the guard is pinned. ## Scope `src/startup_stubs/chad.cpp` and `tests/startup_chad_check.cpp`. No docs change: `docs/startup-runtime.md` mentions `chad.dll` only as a produced file, and the placeholder-success sentence it did carry is in the test, which this updates. The real provider, `XApu` and audible XAudio2 output are untouched, as asked. ## Notes - AI-assisted.
upstream-sync closed this pull request 2026-11-24 21:27:31 +00:00
tedin7 commented 2026-11-24 21:27:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T21:01:24Z.

Review: COMMENTED


Review of head 06d5d72cde (first review; no P1).

Commands executed locally:

  • git diff --check origin/main...HEAD: exit 0, clean
  • python3 tests/bidi_controls_check.py: exit 0, self-test passed, 1337 files, no bidirectional controls
  • Win2025 (Build 26100, MSVC 14.44), targets d3d12_xs_shim, startup_chad_check, startup_stub_* and xmem_shim, regex ^(startup_chad_check|startup_storage_directory_batch|startup_stubs)$: Debug 3/3 passed, Release /O2 3/3 passed
  • Mutation: removed *status_out = nullptr; in XDspActivate (src/startup_stubs/chad.cpp), rebuilt and ran startup_chad_check on Win2025 via win2025 --wt: FAIL "XDspActivate -> XDSP_E_NO_DEVICE_RESOURCES with both outputs cleared" (1 failure), so the test covers the output clearing. Mutation reverted.

Read-through: pointer validation order, E_POINTER vs E_INVALIDARG vs the new code, untouched caller outputs on every failure path and the accept() trap in non-permissive mode all look right. The two consumers of these exports in the tree (startup_stub_consumer, startup_stubs) still pass.

P2 (non-blocking):

  • 0x8AC810A2 / XDSP_E_NO_DEVICE_RESOURCES is cited as a Microsoft GDK code, but nothing in the tree backs the value, and I could not confirm it from the repo. Please link the header or doc where it comes from, or note that it is unverified, so the next reader does not take it as an ABI claim.
  • A handle stays "known" after XDspDisconnect, because the check compares against the static connection address. Harmless for a stand-in; a one-line comment would be enough.
  • The submit test with a known handle goes through connect first, which is good; consider also asserting the E_POINTER path for a null sequence pointer with the known handle (that branch has no test).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6047337527 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1907#pullrequestreview-6047337527). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T21:01:24Z. **Review:** COMMENTED --- Review of head 06d5d72cdef116c2326c18213b28ad12231aebcf (first review; no P1). Commands executed locally: - `git diff --check origin/main...HEAD`: exit 0, clean - `python3 tests/bidi_controls_check.py`: exit 0, self-test passed, 1337 files, no bidirectional controls - Win2025 (Build 26100, MSVC 14.44), targets d3d12_xs_shim, startup_chad_check, startup_stub_* and xmem_shim, regex `^(startup_chad_check|startup_storage_directory_batch|startup_stubs)$`: Debug 3/3 passed, Release /O2 3/3 passed - Mutation: removed `*status_out = nullptr;` in XDspActivate (src/startup_stubs/chad.cpp), rebuilt and ran startup_chad_check on Win2025 via `win2025 --wt`: FAIL "XDspActivate -> XDSP_E_NO_DEVICE_RESOURCES with both outputs cleared" (1 failure), so the test covers the output clearing. Mutation reverted. Read-through: pointer validation order, E_POINTER vs E_INVALIDARG vs the new code, untouched caller outputs on every failure path and the accept() trap in non-permissive mode all look right. The two consumers of these exports in the tree (startup_stub_consumer, startup_stubs) still pass. P2 (non-blocking): - 0x8AC810A2 / XDSP_E_NO_DEVICE_RESOURCES is cited as a Microsoft GDK code, but nothing in the tree backs the value, and I could not confirm it from the repo. Please link the header or doc where it comes from, or note that it is unverified, so the next reader does not take it as an ABI claim. - A handle stays "known" after XDspDisconnect, because the check compares against the static `connection` address. Harmless for a stand-in; a one-line comment would be enough. - The submit test with a known handle goes through connect first, which is good; consider also asserting the E_POINTER path for a null sequence pointer with the known handle (that branch has no test). AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-24 21:27:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T21:12:02Z.

Review: COMMENTED


Retest of head f3d96d31182524445f7a2f7517646931e8e3dc24 (previously reviewed at 06d5d72c; the PR was already MERGED when I finished, so this is a post-merge comment).

Verdict: no P1, no new P2. Merge was fine.

What changed since the first review

git diff 06d5d72c f3d96d31 touches only docs/startup-runtime.md (the X2W_AUDIO_PERMISSIVE=1 row). The new wording matches src/startup_stubs/chad.cpp: valid outputs of XDspActivate are cleared and XDSP_E_NO_DEVICE_RESOURCES is returned, and failed XDspSubmitCommand calls leave the sequence untouched. No code change, so the earlier Windows result still applies, but I reran it on the new head.

Commands run locally

  • git diff --check origin/main...HEAD: exit 0.
  • tests/docs_links_check.py: "Checked 18 Markdown files and 377 links".
  • tests/bidi_controls_check.py: 1337 files, no bidirectional controls.
  • Windows Server 2025 (Build 26100, MSVC 14.44) via the pipeline, regex ^(startup_chad_check|startup_storage_directory_batch|startup_stubs)$: Debug 3/3 and Release /O2 3/3 passed.
  • Mutation from the first review (drop *status_out = nullptr;) was not repeated, since chad.cpp is unchanged.

Still open from the first review (P2/P3, non-blocking)

  • src/startup_stubs/chad.cpp:19: 0x8AC810A2 is attributed to "Microsoft GDK error codes", but nothing in the tree backs the value. A link or an "unverified" note would keep it from reading as an ABI fact.
  • src/startup_stubs/chad.cpp:~99 (the sequence_out check in XDspSubmitCommand): the E_POINTER path for a known handle with a null or unwritable sequence pointer still has no test in tests/startup_chad_check.cpp.
  • A handle stays "known" after XDspDisconnect (the check compares against the static connection). Harmless for a stand-in.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6047486545 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1907#pullrequestreview-6047486545). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T21:12:02Z. **Review:** COMMENTED --- Retest of head `f3d96d31182524445f7a2f7517646931e8e3dc24` (previously reviewed at `06d5d72c`; the PR was already MERGED when I finished, so this is a post-merge comment). **Verdict: no P1, no new P2. Merge was fine.** ### What changed since the first review `git diff 06d5d72c f3d96d31` touches only `docs/startup-runtime.md` (the `X2W_AUDIO_PERMISSIVE=1` row). The new wording matches `src/startup_stubs/chad.cpp`: valid outputs of `XDspActivate` are cleared and `XDSP_E_NO_DEVICE_RESOURCES` is returned, and failed `XDspSubmitCommand` calls leave the sequence untouched. No code change, so the earlier Windows result still applies, but I reran it on the new head. ### Commands run locally - `git diff --check origin/main...HEAD`: exit 0. - `tests/docs_links_check.py`: "Checked 18 Markdown files and 377 links". - `tests/bidi_controls_check.py`: 1337 files, no bidirectional controls. - Windows Server 2025 (Build 26100, MSVC 14.44) via the pipeline, regex `^(startup_chad_check|startup_storage_directory_batch|startup_stubs)$`: Debug 3/3 and Release /O2 3/3 passed. - Mutation from the first review (drop `*status_out = nullptr;`) was not repeated, since `chad.cpp` is unchanged. ### Still open from the first review (P2/P3, non-blocking) - `src/startup_stubs/chad.cpp:19`: `0x8AC810A2` is attributed to "Microsoft GDK error codes", but nothing in the tree backs the value. A link or an "unverified" note would keep it from reading as an ABI fact. - `src/startup_stubs/chad.cpp:~99` (the `sequence_out` check in `XDspSubmitCommand`): the `E_POINTER` path for a known handle with a null or unwritable sequence pointer still has no test in `tests/startup_chad_check.cpp`. - A handle stays "known" after `XDspDisconnect` (the check compares against the static `connection`). Harmless for a stand-in. AI-assisted; commands listed were executed locally.
R0Y00 commented 2026-11-24 21:27:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T21:05:37Z.


Independent Release startup_chad_check passed on 06d5d72c. I updated the existing startup switch row to describe the activation/submit failures and their output behavior. The code and tests are unchanged in this follow-up.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7144465639 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1907#issuecomment-7144465639). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T21:05:37Z. --- Independent Release startup_chad_check passed on 06d5d72c. I updated the existing startup switch row to describe the activation/submit failures and their output behavior. The code and tests are unchanged in this follow-up.
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!1900
No description provided.