Skip to content

macOS: TestASoundDecodesOnceAndPlaysOverlapping segfaults intermittently in CI #801

Closed

Description

@houko

Context

TestASoundDecodesOnceAndPlaysOverlapping (internal/platform/apple/audio_test.go:191) crashed the test process on the macOS runner in the apple job of run 44473406980 (job 135388068649, attempt 1), on a PR that changed only docs (#791):

✓ TestAuthenticationServicesLoads (280ms)
✗ TestASoundDecodesOnceAndPlaysOverlapping (0s)
    signal: segmentation fault
    the test process exited before reporting an outcome

The rerun of the same commit passed (2.65s), and the test had not failed in the previous 40 runs. The log has no Go stack, so the fault is most likely in native code (AVAudioEngine or the decode path) rather than a Go panic.

Why it matters

A segfault in the audio backend could also crash an app loading or playing a sound, not just the test. As a flake it also fails unrelated PRs' apple job.

Proposal

  • Have nsgo test keep the crashing process's native backtrace (or the macOS crash report from ~/Library/Logs/DiagnosticReports) in the job log, so a native fault in any test is diagnosable from CI.
  • Run the test in a loop on macOS (-count=200) to reproduce it, and check the load path for an engine or buffer used before it is ready or after it is released.

Acceptance

  • The cause is found and fixed, or the crash report is captured from CI the next time it happens.
  • go test -count=200 -run TestASoundDecodesOnceAndPlaysOverlapping ./internal/platform/apple passes on macOS.

Activity

  1. self-assigned this
    on Nov 19, 2026
  2. houko commented on Nov 19, 2026

    @houko
    CollaboratorAuthor

    The crash-report capture from #804 did not catch this. The segfault hit the apple job twice on PR #802 (run 44501153803, attempts 1 and 2): the failure-only step ran, but no file under ~/Library/Logs/DiagnosticReports was newer than the job's start marker, and the test step showed only signal: segmentation fault and "the test process exited before reporting an outcome", with no Go traceback.

    So either ReportCrash does not write a report for this process on the runner (or writes it after the step's 10 seconds, or elsewhere), and nsgo test does not show the dead test process's stderr, where the Go runtime prints its SIGSEGV dump with every goroutine.

    Next steps that would make the next occurrence diagnosable:

    • Have nsgo test print the test process's stderr when it dies without reporting an outcome, and run it with GOTRACEBACK=crash so a fault in native code also dumps the Go side and the C frames the runtime can see.
    • In CI, wait longer for ReportCrash and also look under /Library/Logs/DiagnosticReports and ~/Library/Logs/DiagnosticReports/Retired.

    It is now the most frequent flake: three times today (#791 and twice on #802).

  3. houko commented on Nov 20, 2026

    @houko
    CollaboratorAuthor

    I audited the current AVAudio backend and the reported test remains present. The failure is an unconfirmed native AVAudioEngine/AVAudioPlayerNode crash with no Go backtrace, and this environment cannot run the macOS target or collect a macOS DiagnosticReports crash log. I found no source-level evidence that identifies the failing native call, so I did not submit a speculative audio lifecycle change. The issue should remain open for a macOS CI reproduction with a native backtrace.

  4. houko commented on Nov 22, 2026

    @houko
    CollaboratorAuthor

    Closing as addressed by changes already on main, with fresh native verification rather than another implementation PR.

    • c409c5d66 keeps each sound voice's mixer and main-mixer input bus attached while replacing its upstream player/rate nodes for another audio format. It also adds a regression for mixer reuse across formats.
    • 84d2eb478 preserves package diagnostics when a test process dies before reporting an outcome. The Apple workflow now enables GOTRACEBACK=crash, retains debug symbols, stresses the authentication/audio ordering in 200 fresh processes, and searches both user and system DiagnosticReports recursively after failure.
    • On macOS arm64 at current main 091984681603d03095e491025b499e3cc11d00df, I ran go tool nsgo test -ldflags '-s=false -w=false' -run '^TestASoundDecodesOnceAndPlaysOverlapping$' ./internal/platform/apple -- -count=200 -timeout=20m with GOTRACEBACK=crash: 200 passed, 0 failed, 0 skipped. The native run completed in about 1 minute 51 seconds on the Mac Studio.

    The historical crash had no native backtrace, so its exact faulting instruction cannot be recovered from that log. The mixer lifetime fix and the requested diagnostics/stress coverage are now present, and the issue's explicit 200-iteration acceptance passes.

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

Metadata

Metadata

Assignees

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