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

Sentry crashes if en0 is not the primary ethernet interface on macOS

Open itspolly opened this issue 4 years ago • 2 comments

Environment

How do you use Sentry? On-premise

Which SDK and version? sentry-cocoa 7.0.3

Steps to Reproduce

  1. Change the primary ethernet interface to en1, or remove en0
  2. Launch a macOS app using the Sentry SDK

Note: these steps involve deliberately changing the primary ethernet interface away from en0 if it is en0, but Apple recommends against assuming en0 exists at all and assuming it is the primary interface and we've seen this crash in our app with users on stock systems.

Expected Result

Sentry doesn't crash.

Actual Result

Sentry crashes with the following error:

ERROR: SentryCrashSysCtl.c (214): _Bool sentrycrashsysctl_getMacAddress(const char *const, char *const): Could not get interface index for en0: Device not configured
ERROR: SentryCrashMachineContext.c (230): void sentrycrashmc_resumeEnvironment(): thread_resume (00006707): (os/kern) invalid argument
[1] 4403 illegal hardware instruction

This issue occurs because getDeviceAndAppHash uses sentrycrashsysctl_getMacAddress to get the MAC address of the system, but assumes that the default interface is always on en0, when in fact, some systems do not have an en0:

From Apple's sample code on getting a MAC address:

// Note that another option here would be:
// matchingDict = IOBSDMatching("en0");
// but en0: isn't necessarily the primary interface, especially on systems with multiple Ethernet ports.

I've already written a patch for this and will open a PR soon.

itspolly avatar May 07 '21 12:05 itspolly

Might be a different issue, but the following error keep occurring from an hour ago somehow.

  • sentry_flutter: v6.5.0
  • macOS: 12.1
ERROR: SentryCrashCPU.c (58): _Bool sentrycrashcpu_i_fillState(const thread_t, const thread_state_t, const thread_state_flavor_t, const mach_msg_type_number_t): thread_get_state: (ipc/send) invalid destination port
ERROR: SentryCrashMachineContext.c (232): void sentrycrashmc_resumeEnvironment(): thread_resume (0001b913): (os/kern) failure

Edit: After upgrading sentry_flutter to v6.5.1, flutter clean and re-run my app, it started working.

tomoyuki28jp avatar Jun 05 '22 02:06 tomoyuki28jp

Edit: After upgrading sentry_flutter to v6.5.1, flutter clean, and re-run my app, it started working.

I'm happy that it works now, so I don't think that this is related.

philipphofmann avatar Jun 10 '22 09:06 philipphofmann

Closing this as it worked when upgrading to sentry_flutter to v6.5.1. Please reopen if the issue persists.

philipphofmann avatar Feb 28 '24 13:02 philipphofmann