Skip to content

mac: SIGSEGV in didStopWithError when logging Error (still on 1.17.0) #236

Description

@bigBearyd

Summary

macOS OpenDisplay 1.17.0 (141) still crashes with EXC_BAD_ACCESS / SIGSEGV in stream(_:didStopWithError:) when ScreenCaptureKit stops the capture stream. The same stack appeared on 1.16.1; upgrading to 1.17.0 did not fix it.

This looks distinct from #231: the process dies while formatting/logging error, before the new SCStreamError.userStopped / recovery logic can run. App logs never contain stream stopped with error: for these crashes.

Environment

  • Mac app: 1.17.0 (141) (also reproduced on 1.16.1 / 137)
  • macOS: 14.4.1 (23E224)
  • Hardware: MacBook Pro (MacBookPro18,3), Apple M1 Pro, 16 GB
  • Mode: WiFi extend to iPhone
  • Screen Recording + Accessibility: granted

Steps

  1. Connect iPhone over WiFi and start extend.
  2. Leave the session running (capture FPS often collapses to ~0–2 with stalls on this network).
  3. After some time, ScreenCaptureKit stops the stream (didStopWithError).
  4. OpenDisplay quits immediately (segmentation fault).

Crash signature

  • Exception: EXC_BAD_ACCESS / SIGSEGVKERN_INVALID_ADDRESS at 0x0
  • Triggered from: -[SCStreamManager stream:didStopWithError:] → OpenDisplay → Swift _print_unlocked / swift_getDynamicType / SwiftError::isPureNSError

Faulting frames (1.17.0 build, OpenDisplay-2026-08-21-111218.ips):

libswiftCore.dylib +4216972
libswiftCore.dylib +3792708
libswiftCore.dylib +887964
OpenDisplay +94644
OpenDisplay +96052
ScreenCaptureKit +138400
ReplayKit +103884
ReplayKit +155640
CoreFoundation +386100
CoreFoundation +385716
ReplayKit +143500
Foundation +8901188

Suspected cause

In Mac/MacSender.swift (v1.17.0):

func stream(_ stream: SCStream, didStopWithError error: Error) {
    guard stream === self.stream else { return }
    Log.info("stream stopped with error: \(error)")  // ← crashes here
    ...
}

Crash stack goes through Swift error printing (_print_unlocked), which suggests the bridged Error from ScreenCaptureKit/ReplayKit is sometimes invalid/null, and string interpolation forces a dynamic type/print that segfaults.

Suggested fix

Avoid interpolating the raw Error until it is known-safe, e.g.:

Notes

  • Reproduced multiple times on 2026-08-21 after updating to 1.17.0 (…-111136.ips, …-111218.ips), and earlier on 1.16.1 the same day.
  • WiFi session shows very low capFps/fps and rising stalls beforehand; that likely increases how often the stream stops and hits this path.
  • Happy to attach full .ips + ~/Library/Logs/OpenDisplay/opendisplay.log if useful.

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions