Repository navigation
fix(desktop): report helper crashes with their stack - #307
Merged
Merged
Conversation
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Scope
native/voice-helper/Sources/VoiceHelper/main.swiftcallstask_set_exception_portswithMACH_PORT_NULLforEXC_MASK_CRASH | EXC_MASK_RESOURCE | EXC_MASK_GUARD.apps/desktop/src/main/helper-crash.tsadds two functions:parseCrashReportreads one.ipsreport. 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.findHelperCrashwaits up to 10 s for that report in~/Library/Logs/DiagnosticReports.diagnostics.ts:helperExitedlooks up the report for a signal exit, then sends the event throughcaptureEventwith anEXC_*exception.HelperExitnow carries the helperpid.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
crashReporteron, I spawned the built helper and sent it SIGABRT, then SIGSEGV. Each crash wrote a Crashpad minidump of the helper (2 of 2).stringsshowed the helper'sPWDand executable path in the dump.voice-helper-*.ipsreports.kill -SEGVto the instance's helper. The recorder got one event:{"helper.signal":"SIGSEGV"}EXC_CRASH, mechanismhelper.crashVoiceHelper_mainmarked as in-app/Userspath, no attachment, and no native minidump eventvp test runpasses 52 tests acrosshelper-crash,diagnostics,diagnostics-scrub, andhelper. The test commit fails onmainwithexpected [] 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.