startup: fail XDspActivate and XDspSubmitCommand instead of succeeding without outputs #1900
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1907"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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,XDspActivateandXDspSubmitCommandreturned 0 and wrote nothing. A caller thatgates its first submit on activation success then read the status pointer the stand-in never wrote — at
+0xC, the offsetof
resultin the documentedXDspStatus— and stopped with an access violation.Change
src/startup_stubs/chad.cpponly:XDspActivate(client, params, XDspStatus** status, XDspStreamHandle* stream)validates both output pointers, clearsthem, and returns
XDSP_E_NO_DEVICE_RESOURCES(0x8AC810A2).E_POINTERwhen either output is null or unwritable.XDspSubmitCommand(stream, command, uint32_t* sequence)refuses a null or unknown stream handle withE_INVALIDARGwithout writing the sequence, and a known handle still has no device, so the caller's sequence value survives every
failure path.
XDspConnectWithMaximumStreamLimitis unchanged: it still returns S_OK and publishes the handle, so #1871's out-handlechecks stand.
x2w-audiologging are untouched.The two codes are the GDK definitions (
XDSP_E_NO_DEVICE_RESOURCES=0x8AC810A2, next toXDSP_E_QUEUE_FULL=0x8AC810A0), read from Microsoft's error code listrather than assumed.
Tested
tests/startup_chad_check.cppreplaces the two placeholder-success assertions with:XDspActivate(unwritable outputs)E_POINTERXDspActivate(valid outputs)XDSP_E_NO_DEVICE_RESOURCES, both outputs nullXDspActivate(null status*)/(null stream*)E_POINTEReachXDspSubmitCommand(null handle)E_INVALIDARG, sequence still0xdeadbeefXDspSubmitCommand(unknown handle)E_INVALIDARG, sequence still0xdeadbeefXDspSubmitCommand(known handle)XDSP_E_NO_DEVICE_RESOURCES, sequence still0xdeadbeefsequence == 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:return hr_ok;(the old behaviour)*status_out = nullptr;dropped fromXDspActivateXDspSubmitCommandOne mutation I expected to be caught and was not: dropping the null check on
status_outkeeps the test green. Thatone is equivalent rather than uncovered —
x2w_local::accessible()rejects any address below0x10000(
if (start < 0x10000 ... ) return false;), sowritable(nullptr, ...)is already false and the explicit!status_outis documentation. I kept it for intent and am saying so rather than pretending the guard is pinned.
Scope
src/startup_stubs/chad.cppandtests/startup_chad_check.cpp. No docs change:docs/startup-runtime.mdmentionschad.dllonly as a produced file, and the placeholder-success sentence it did carry is in the test, which this updates.The real provider,
XApuand audible XAudio2 output are untouched, as asked.Notes
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, cleanpython3 tests/bidi_controls_check.py: exit 0, self-test passed, 1337 files, no bidirectional controls^(startup_chad_check|startup_storage_directory_batch|startup_stubs)$: Debug 3/3 passed, Release /O2 3/3 passed*status_out = nullptr;in XDspActivate (src/startup_stubs/chad.cpp), rebuilt and ran startup_chad_check on Win2025 viawin2025 --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):
connectionaddress. Harmless for a stand-in; a one-line comment would be enough.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T21:12:02Z.
Review: COMMENTED
Retest of head
f3d96d31182524445f7a2f7517646931e8e3dc24(previously reviewed at06d5d72c; 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 f3d96d31touches onlydocs/startup-runtime.md(theX2W_AUDIO_PERMISSIVE=1row). The new wording matchessrc/startup_stubs/chad.cpp: valid outputs ofXDspActivateare cleared andXDSP_E_NO_DEVICE_RESOURCESis returned, and failedXDspSubmitCommandcalls 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.^(startup_chad_check|startup_storage_directory_batch|startup_stubs)$: Debug 3/3 and Release /O2 3/3 passed.*status_out = nullptr;) was not repeated, sincechad.cppis unchanged.Still open from the first review (P2/P3, non-blocking)
src/startup_stubs/chad.cpp:19:0x8AC810A2is 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(thesequence_outcheck inXDspSubmitCommand): theE_POINTERpath for a known handle with a null or unwritable sequence pointer still has no test intests/startup_chad_check.cpp.XDspDisconnect(the check compares against the staticconnection). Harmless for a stand-in.AI-assisted; commands listed were executed locally.
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.