sentry-cocoa icon indicating copy to clipboard operation
sentry-cocoa copied to clipboard

`SentryCrashMonitor_MachException` crashes on macOS

Open sindresorhus opened this issue 4 years ago • 11 comments

Environment

Sentry SaaS (sentry.io)

Sentry Cocoa 7.7.0

Steps to Reproduce

  1. Look at this report: https://sentry.io/organizations/sindresorhus/issues/2884292704/events/a191dd6573534c37aa3b87fd18430a52/
  2. 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.

sindresorhus avatar Dec 26 '21 00:12 sindresorhus

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.

philipphofmann avatar Dec 28 '21 15:12 philipphofmann

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 🥀

github-actions[bot] avatar Jan 18 '22 15:01 github-actions[bot]

Please keep this open.

sindresorhus avatar Jan 18 '22 16:01 sindresorhus

Experiencing (I think) similar issue on iOS

https://sentry.io/organizations/island-magic-co/issues/3342986887/events/c1620d1f11ae43d080534c4a83d7387a/?project=6375329

georges avatar Sep 10 '22 02:09 georges

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/

sindresorhus avatar Sep 11 '22 10:09 sindresorhus

I'm sorry about that, @sindresorhus. I will bump the priority for this issue.

philipphofmann avatar Sep 14 '22 09:09 philipphofmann

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

philipphofmann avatar Jan 30 '23 15:01 philipphofmann

@sindresorhus, do you still see this crash happening? If yes, can you provide us with a link?

philipphofmann avatar Jan 30 '23 15:01 philipphofmann

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 avatar Jan 30 '23 16:01 sindresorhus

@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.

philipphofmann avatar Dec 01 '23 08:12 philipphofmann

Do you call SentrySDK.close somewhere in your code?

No

sindresorhus avatar Dec 01 '23 09:12 sindresorhus