Skip to content

fix(desktop): report helper crashes with their stack - #307

Merged
hadrysm merged 4 commits into
mainfrom
fix/sentry-mcp-issues
Oct 22, 2026
Merged

hadrysm merged 4 commits into
mainfrom
fix/sentry-mcp-issues

Conversation

@hadrysm

@hadrysm hadrysm commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Why

Sentry has two open issues for the Swift helper, and neither can be acted on. VOICE-4 ("Voice helper exited unexpectedly") reports only the signal: SIGSEGV, SIGTRAP, SIGABRT, or SIGKILL. VOICE-5 is an empty native event with no stack.

VOICE-5 comes from the helper too. Node spawns the helper, so the helper inherits the task exception ports that Electron's Crashpad registers. Each helper crash then becomes a Crashpad minidump. The minidump holds the helper's memory and environment. The scrubber drops dumps for privacy, so Sentry gets an empty duplicate of the VOICE-4 crash.

This PR gives helper crashes a stack without sending a dump:

  • The helper clears the inherited ports at startup, so only macOS reports its crashes.
  • Main reads the macOS crash report for the helper's pid. It sends the crashed thread's image names and symbols with the existing exit event.

Scope

  • native/voice-helper/Sources/VoiceHelper/main.swift calls task_set_exception_ports with MACH_PORT_NULL for EXC_MASK_CRASH | EXC_MASK_RESOURCE | EXC_MASK_GUARD.
  • apps/desktop/src/main/helper-crash.ts adds two functions:
    • parseCrashReport reads one .ips report. It keeps only the exception type and the crashed thread's image names and symbols, and drops registers, other threads, paths, and the crash message.
    • findHelperCrash waits up to 10 s for that report in ~/Library/Logs/DiagnosticReports.
  • diagnostics.ts:
    • helperExited looks up the report for a signal exit, then sends the event through captureEvent with an EXC_* exception.
    • Other exits are sent as before.
    • The existing rule of one report per exit kind per launch stays.
  • HelperExit now carries the helper pid.

Tradeoffs

Sending the Crashpad minidump would give a full stack. It would also send the helper's memory and environment, and the scrubber exists to prevent that. The macOS report gives the same crashed-thread symbols, and we parse only the fields we need.

Blast Radius

These changes only run when diagnostics sharing is on and the helper dies from a signal. Crashes in Electron itself still go to Crashpad as before. The privacy page already lists crash reports. The new events contain function and image names, with no words, audio, paths, or username.

Verification

  • Repro, before the fix. In an Electron app with crashReporter on, I spawned the built helper and sent it SIGABRT, then SIGSEGV. Each crash wrote a Crashpad minidump of the helper (2 of 2). strings showed the helper's PWD and executable path in the dump.
  • After the Swift fix. The same probe with SIGABRT, SIGSEGV, and SIGTRAP wrote 0 dumps. macOS still wrote all 3 voice-helper-*.ips reports.
  • End to end. I used the verify skill: a test-mode instance built with a DSN that points at a local envelope recorder, with sharing on. I sent kill -SEGV to the instance's helper. The recorder got one event:
    • tags {"helper.signal":"SIGSEGV"}
    • exception EXC_CRASH, mechanism helper.crash
    • 11 named frames, with VoiceHelper_main marked as in-app
    • no /Users path, no attachment, and no native minidump event
  • Tests. vp test run passes 52 tests across helper-crash, diagnostics, diagnostics-scrub, and helper. The test commit fails on main with expected [] to deeply equal [ 4242 ]. Deliberately broken versions of the parser fail the new tests.

The stacks in VOICE-4 so far are not reproducible yet. The next helper crash on a build with this fix will carry its stack, and that stack decides the real crash fix.

A helper that dies from a signal was reported with only the signal name,
so Sentry issue VOICE-4 could not show where the helper crashed.

findHelperCrash now waits for the macOS crash report of the helper's pid
and keeps only the crashed thread's image names and symbols. The event
carries them as an EXC_* exception, so Sentry groups crashes by stack.
The helper inherited the task exception ports that Electron's Crashpad
registers, so every helper crash also became a minidump in Electron's
crash folder. Sentry received it as an empty native event (VOICE-5),
because the scrubber drops dumps. The dump also held the helper's memory
and environment on disk.

The helper now clears those ports at startup. macOS still writes its own
crash report, which main reads for the stack.
@github-actions github-actions Bot added the size:L 100-499 effective changed lines (test files excluded in mixed PRs). label Oct 22, 2026
The scenario command removed its SIGINT and SIGTERM handlers after
teardown, before it printed its report and exited. A Ctrl+C in that gap
ended the process by signal instead of with the scenario status. The test
"repeated signals during teardown do not leave the instance running"
hit the gap in 4 of 24 local runs and failed CI on #307.

The handlers now stay until the command exits. The test passed 48 of 48
local runs.
@hadrysm
hadrysm merged commit 74b58d6 into main Oct 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 effective changed lines (test files excluded in mixed PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant