Skip to content

startup-runtime: audio stand-ins return success without writing the outputs their callers read #1887

Backlog

Description

@NiiRoZz

Commit or build

Upstream main at 8c82879.

Summary

With X2W_AUDIO_PERMISSIVE=1, several exports of the audio stand-ins return success without writing the outputs their callers pass. One of them is confirmed to end a run (the DSP activation); the others have the same shape and have not been checked against their callers. This issue lists them so they can be checked one by one.

Reproduction

# Any source-built probe that loads chad.dll with X2W_AUDIO_PERMISSIVE=1 and calls
#   XDspActivate(client, &params, &status, &stream)
# with status and stream preset to a sentinel gets 0 back and both outputs untouched.
# Read from the source at 8c82879f: src/startup_stubs/chad.cpp, accept() returns 0 for
# XDspActivate, XDspSubmitCommand, XDspDeactivate and XDspDisconnect and writes nothing.

Expected behavior

An export either writes outputs that are valid for what the caller does next, or returns a failure the caller can handle. The public XDspAudio.h reference documents XDspActivate(client, XDspActivationParameters*, XDspStatus** status, XDspStreamHandle* stream), XDspSubmitCommand(stream, XDspCommand*, uint32_t* commandSequence), the status block {lastSubmittedCommandSequence, lastProcessedCommandSequence, firstFailedCommandSequence, HRESULT result} and failure codes such as XDSP_E_NO_DEVICE_RESOURCES.

Observed behavior

Confirmed case, XDspActivate (chad.cpp): returns 0, writes neither the status pointer nor the stream handle. Limited observation from one local startup run, repeated once without and once under the startup debugger: after six activations the executable called XDspSubmitCommand six times with a null stream handle (also answered with 0), then read through the null status pointer at offset 0xC, which is the offset of result in the documented status block, and stopped with an access violation. The values were read from the stand-in log lines (x2w-audio) and from the debugger's stop report; no package data is involved.

Same shape, callers not checked:

Export File What it does today Status
XDspActivate chad.cpp 0, no outputs written ends a run (above)
XDspSubmitCommand chad.cpp 0 for any handle including null, sequence not written reached with a null handle in the same run
XDspDeactivate, XDspDisconnect chad.cpp 0 for any handle not checked
XDspConnectWithMaximumStreamLimit chad.cpp 0 even when the handle pointer is null or not writable #1871 addresses this one
XApuConnect xapu.cpp writes the handle (third argument) but never the 16-byte second argument it logs as output(before) not checked whether the caller reads it
XApuDequeueResult xapu.cpp S_OK with an all-zero 0x58-byte result already documented as a placeholder in docs/startup-runtime.md
AcpHal slot 0 (connect), slot 2 (submit) acphal.cpp S_OK, nothing written at one submit call site read locally the pointer argument is not read back; others not checked

Related

A local fixture for the XDsp rows exists (activation refused with the documented code and both outputs set to null; null and unknown handles refused; negative control: success without outputs must fail). It is not submitted because it conflicts with the test in #1871; the direction for those two rows is the maintainers' call.

Environment

Windows 11 build 26300, MSVC 19.44 x64. No GPU involved.

Checklist

  • I reproduced this on a source-built input. (The stand-in behavior; the run-ending consequence is a local observation as described.)
  • I did not include game files, dumps, distribution links or credentials.

AI-assisted (Claude Code): the source reading, the fixture and the local observation were produced with AI agents.

Activity

  1. R0Y00 commented on Nov 24, 2026

    @R0Y00
    Owner

    Please open the narrow failure-only XDsp slice using the source-built fixture you already have. If there is no usable stream provider in permissive mode, validate both output pointers before writing; for valid output locations, clear them and return XDSP_E_NO_DEVICE_RESOURCES. Refuse null and unknown stream handles on submit without returning a sequence; preserve the caller's sequence output on failure. Keep the strict trap coverage and #1871's connect out-handle checks. Update the placeholder-success assertions for the two exports whose behavior changes.

    Acceptance is a synthetic caller that gates its first submit on activation success, checks initialized outputs and unchanged failed-submission sequence, and fails when the old successful no-output behavior is restored. Keep the real provider, XApu and audible XAudio2 output on their existing tracks.

    Microsoft XDSP error codes.

  2. ChazY11 commented on Nov 24, 2026

    @ChazY11
    Contributor

    Opened #1907 as the narrow failure-only slice you described: XDspActivate validates and clears both outputs then returns
    XDSP_E_NO_DEVICE_RESOURCES (0x8AC810A2, from the GDK error list rather than assumed), XDspSubmitCommand refuses null
    and unknown handles without writing the sequence and still preserves it on the known-handle failure, and #1871's connect
    out-handle checks stay as they are.

    The fixture is built from source in the PR: the synthetic caller gates its first submit on activation success and never
    reaches submit, and restoring the old successful-no-output behaviour fails the run.

    One detail from the negative controls worth recording here: the explicit !status_out null checks are equivalent, not
    untested — x2w_local::accessible() already rejects addresses below 0x10000, so writable(nullptr, ...) is false. I kept
    them for intent and said so in the PR instead of claiming they are pinned.

    • AI-assisted.
  3. R0Y00 commented on Nov 24, 2026

    @R0Y00
    Owner

    The failure-only XDsp fix #1907 is on main at 87f280f. The source-built activation caller now receives cleared outputs and XDSP_E_NO_DEVICE_RESOURCES and does not submit a command. The strict trap and connect controls still pass. Keeping this issue open for the remaining out-parameter cases. This test does not establish an audible provider or application audio.

  4. R0Y00 commented on Nov 24, 2026

    @R0Y00
    Owner

    #1967 is on main at 34472a5. Native Windows Release startup_xapu_queue passed. A fresh or drained XApu queue now reports XAPU_E_PENDING_RESULTS and leaves every byte of the supplied result buffer intact. The remaining output-field checks and application audio work stay open here.

  5. roansystemlabs commented on Nov 25, 2026

    @roansystemlabs
    Contributor

    I'd like to take two of the remaining rows that nobody has checked yet: XDspDeactivate and XDspDisconnect, and the 16-byte second argument of XApuConnect. If someone already has it in progress, I'll step back and review.

    I'm leaving the AcpHal slots 0 and 2 out for now, since #1902 is open on src/startup_stubs/acphal.cpp; I can take them after it lands if they are still open.

    Scope: one PR per stand-in. For each export, either write outputs that are valid for the documented next call, or return a documented failure with the outputs cleared, following the shape of #1907. No change to the permissive switch itself or to #2107's counters.

    Evidence: a source-built caller per export with sentinel-filled outputs and null/unknown handles; a negative control that fails when the export returns success without writing. Windows Release, MSVC. No GPU, no application input.

    AI-assisted.

  6. R0Y00 commented on Nov 25, 2026

    @R0Y00
    Owner

    The XApu completion fields landed in #2242 (ef2e014). Independent Windows Release checks passed for the production FIFO and the source-built native/mapped caller, including full-queue refusal and the existing wrong-order and invalid-handle controls. The result now reports the queued type and slot. Decoded bytes remain zero, and the existing XApuConnect/XDsp observations remain open.

  7. lukaslw-lab commented on Nov 25, 2026

    @lukaslw-lab
    Contributor

    #2242 (ef2e0143) stops the startup run here shortly after the title screen. With #2242 reverted on the same build, the run continues.

    Build Run Result
    main e94e14ff (includes #2242) 1 second-chance access violation at 45.6 s
    the same 2 the same, at 48.0 s
    the same + local revert of #2242 3 no stop, 90 s time limit, 1,609 frames

    All three builds also carry a local timing-only change in the present path (QueryPerformanceCounter around its parts); it does not touch audio.

    • Where: a 160-byte copy to a null destination in the title, with xapu.dll frames on the stack. The last audio calls logged before it are XApuEnqueueCommand (type 1) and the first XApuDequeueResult.
    • When: about 0.4 s after the first A press at the title screen is read, in both runs.
    • What I take from it: the title now gets the queued type and slot back and acts on them. In the path it then takes, it copies into a buffer the stand-in never provided. That is an inference from the log order; I have not traced the copy.
    • Before startup: populate XApuDequeueResult type and slot fields #2242 we had 100+ startup runs on this host past this point without a stop here.

    Setup: Windows 10 19045, RTX 3080 Ti, Release, tools/startup/run.ps1 -Render -Translate -FakeUser -GpuMirror -HostCpu -StartupBelow40 (which sets X2W_AUDIO_PERMISSIVE=1). Counts only; logs stay local.

    AI-assisted (Claude Code).

  8. JB2WIN commented on Nov 25, 2026

    @JB2WIN
    Contributor

    Same stop on a second host, and the local revert clears it here as well.

    Build Run Result
    main 540a9615 (includes #2242) 1 second-chance access violation in a 160-byte copy to a null destination at 78.1 s, xapu.dll frame on the stack
    the same, -MemoryGiB 20 instead of 14 2 the same, at 80.1 s; commit peak 12.2 GiB, so not the job cap
    the same + local revert of ef2e0143 (only xapu.dll rebuilt) 3 no stop, 180 s time limit, 5,078 frames presented

    In both stopping runs the title read the first A press about 0.4 s before the stop, and the last audio calls logged were XApuEnqueueCommand (type 1) and the first XApuDequeueResult, as in the report above. I have not traced the copy either.

    Setup: Windows 11 Pro 26200, i5-13600K, RTX 3080 (driver 32.0.16.2124), Release, tools/startup/run.ps1 -Render -Translate -FakeUser -GpuMirror -HostCpu -ContinueAsserts 1000 -InputScript "4@70" -StoragePath <dir>. Counts only; logs stay local.

    AI-assisted (Claude Code).

  9. R0Y00 commented on Nov 25, 2026

    @R0Y00
    Owner

    The two independent matched reverts are enough to prioritize this regression. #2268 restores zeroed permissive results by default and keeps the typed queue as an explicit experiment. The source-built test catches the original default behavior and still exercises the typed FIFO.

    For the exact PR build, please repeat the same startup sequence with X2W_XAPU_TYPED_COMPLETIONS unset. Record whether it passes the first A press and the first dequeue, the next stopping point, and the Windows build. The consumer-side output needed for typed completions is still open in this thread.

  10. R0Y00 commented on Nov 25, 2026

    @R0Y00
    Owner

    The XApuConnect shared-buffer change is on main in #2288. The source-built Windows check passed for zeroed, writable storage on two separate connections and for invalid calls leaving the outputs alone. The buffer is returned with permissive audio; typed completions are still opt-in.

    For the two prior reports, the focused A/B is one build with permissive audio and the same first A press, first with X2W_XAPU_TYPED_COMPLETIONS unset and then with it set to 1. Please report the commit, Windows build, whether each run reaches the first dequeue and passes the prior stop, and the next stopping point if any. The fixture establishes the connection buffer contract; this replay is the outstanding evidence for the caller's copy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions