`SentryCrashMonitor_MachException` crashes on macOS
Environment
Sentry SaaS (sentry.io)
Sentry Cocoa 7.7.0
Steps to Reproduce
- Look at this report: https://sentry.io/organizations/sindresorhus/issues/2884292704/events/a191dd6573534c37aa3b87fd18430a52/
- Notice how it crashed in "Sources/SentryCrash/Recording/Monitors/SentryCrashMonitor_MachException.c:266"
libsystem_kernel 0x189c29954 mach_msg_trap
libsystem_kernel 0x189c29cfc mach_msg
Lungo 0x10024cb20 handleExceptions (Sources/SentryCrash/Recording/Monitors/SentryCrashMonitor_MachException.c:266)
libsystem_pthread 0x189c6523c _pthread_start
Expected Result
I expected the crash monitor to not crash.
Actual Result
It crashed.
The crash happened for a random user. I cannot reproduce it myself.
Thanks for reporting this @sindresorhus. I noticed that KSCrash has a few fixes for KSCrashMonitor_MachException over the past year, that we don't include in SentryCrash. I think we should apply those fixes to your repo.
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!
"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀
Please keep this open.
Experiencing (I think) similar issue on iOS
https://sentry.io/organizations/island-magic-co/issues/3342986887/events/c1620d1f11ae43d080534c4a83d7387a/?project=6375329
I had to remove Sentry from one of my apps as there were too many random crashes caused by Sentry itself.
For example: https://sentry.io/organizations/sindresorhus/issues/3474609924/events/578f5959e32b4da18217e6af63587102/
I'm sorry about that, @sindresorhus. I will bump the priority for this issue.
https://github.com/getsentry/sentry-cocoa/pull/2662 could fix this, but I'm not sure, as the crash happened https://github.com/getsentry/sentry-cocoa/blob/2814f3c5e624108bda1d0dccfaabbbf00217d6dc/Sources/SentryCrash/Recording/Monitors/SentryCrashMonitor_MachException.c#L265-L267
but we didn't change the code there with https://github.com/getsentry/sentry-cocoa/pull/2662
@sindresorhus, do you still see this crash happening? If yes, can you provide us with a link?
https://sentry.io/organizations/sindresorhus/issues/3395658059/events/237780f493a24bc6a8ca71a7d217a6c2/
https://sentry.io/organizations/sindresorhus/issues/3394531772/events/4fa2d20fe8a94134be5b6eabf73e96a9/
https://sentry.io/organizations/sindresorhus/issues/3902974617/events/d8f0f2cc891e43f4a23a1eacf948cb4b/
@sindresorhus, sorry for getting back to you so late. I checked our internal SDK crashes and see around 50 crashes like that still happening in the past 90 days. It also occurs in v 8.x.
As pointed out by me above, the crash happens while waiting for mach messages. This may happen after closing the SDK, and we don't correctly clear up our mach exception handler. Do you call SentrySDK.close somewhere in your code?
Internal note for further investigation: We made some changes to enable and disable the mach exception handler in this PR https://github.com/getsentry/sentry-cocoa/pull/2440, released with 7.31.3 in Nov 2022.
Do you call SentrySDK.close somewhere in your code?
No