Skip to content

v2.2.0/v2.3.0: sunshine.exe crashes with divide-by-zero on first client connect (0xc0000094 @ RVA 0x1d422f) #106

Backlog

Description

@lj331

sunshine.exe (bundled build, timestamp 0x6b045f79, identical in v2.2.0 and v2.3.0) crashes with STATUS_INTEGER_DIVIDE_BY_ZERO while handling the first client request after a seat session is enabled/recycled. The panel then recycles the session (~40s) and the client receives a truncated response — "Malformed XML (missing root element)" (Error -1). Intermittent but chronic (30 crashes logged); independent of console login state; still present in v2.3.0.

Disassembly of the fault site (template sunshine.exe, md5 ce788b706de9):

RVA 0x1d421d  cmp  r15d, 1
RVA 0x1d4222  jbe  L
RVA 0x1d4224  mov  eax, r8d            ; Y = [rbx+0x128]
RVA 0x1d4227  mov  r9d, [rbx+0x118]    ; divisor Z — can be 0 on first request
RVA 0x1d422e  cdq
RVA 0x1d422f  idiv r9d                 ; ← 0xc0000094
RVA 0x1d4231  test edx, edx / je far   ; exact-division fast path

The divisor [rbx+0x118] has no zero-check. Local workaround: I patched the 7-byte load into a code-cave guard (divisor 0 → treated as 1; non-zero path byte-identical), 30 bytes total, verified by full-file diff. Result: first-connect crash eliminated — friend connected on the first attempt with zero crashes since (session log confirms the patched instance was loaded; last crash 13:30:33, nothing after). No visual/stream anomalies so far.

Suggested fix: zero-check (or init fallback 0→1) for the divisor at that site, and check the init ordering of [rbx+0x128] / [rbx+0x114] nearby. Happy to share more crash logs (30 reproductions with fingerprints).

Activity

  1. mlopezsegura commented on Nov 30, 2026

    @mlopezsegura
    Collaborator

    Thanks for the detailed report — the disassembly pointed straight at the cause.

    The idiv is in display_base_t::capture(), where Sunshine lowers the client frame rate to match a fractional display refresh rate (client_frame_rate % display_refresh_rate_rounded). In your listing, [rbx+0x114] is the refresh-rate denominator, [rbx+0x118] the rounded refresh rate and [rbx+0x128] the client frame rate. Those refresh-rate fields were only filled in by Desktop Duplication. The RemoteIdd capture that seats use never set them, and since that display class has its own constructor they kept whatever was on the heap. When the leftover denominator happened to be above 1 and the rounded rate 0, Sunshine divided by zero. That's why it was intermittent and only hit the first capture after a seat's Sunshine started.

    Fixed in OpenStreamMS 2.3.1 (OpenstreamCo/Sunshine-Web-RTC#12):

    • the refresh-rate fields start at zero;
    • RemoteIdd reads the real refresh rate of the seat's display;
    • the adjustment skips the division when the rate is unknown.

    To update from 2.3.0, use About → Update now, or run the installer. It replaces the bundled Sunshine\sunshine.exe, including your patched copy; if you pointed SunshineExePath at a copy elsewhere, point it back. Sessions pick up the new Sunshine on their next start.

    Could you confirm the first connection works without crashes after updating? I'll close the issue then.

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