Crash on macOS SDK

I have a few of these crashes:

  MyApp              0x00010ce358de -[AppDelegate applicationDidFinishLaunching:] (Sources/AppDelegate.m:60)
  CoreFoundation      0x7ff81f006f23 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
  CoreFoundation      0x7ff81f0a43f9 ___CFXRegistrationPost_block_invoke
  CoreFoundation      0x7ff81f0a4376 _CFXRegistrationPost
  CoreFoundation      0x7ff81efd8836 _CFXNotificationPost
  Foundation          0x7ff81fe201be -[NSNotificationCenter postNotificationName:object:userInfo:]
  AppKit              0x7ff821a4761b -[NSApplication _postDidFinishNotification]
  AppKit              0x7ff821a4736d -[NSApplication _sendFinishLaunchingNotification]
  AppKit              0x7ff821a44f40 -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:]
  AppKit              0x7ff821a44b97 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:]
  Foundation          0x7ff81fe4b194 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:]
  Foundation          0x7ff81fe4b006 _NSAppleEventManagerGenericHandler
  AE                  0x7ff8256a3d27 _AppleEventsCheckInAppWithBlock
  AE                  0x7ff8256a3591 _AppleEventsCheckInAppWithBlock
  AE                  0x7ff82569c9c6 aeProcessAppleEvent
  HIToolbox           0x7ff827c5dc41 AEProcessAppleEvent
  AppKit              0x7ff821a3f222 _DPSNextEvent
  AppKit              0x7ff821a3d3f4 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
  AppKit              0x7ff821a2f919 -[NSApplication run]
  AppKit              0x7ff821a037b7 NSApplicationMain

Code is:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    [SentrySDK startWithOptions:@{
        @"dsn": @"https://..."
    }];
    [SentrySDK configureScope:^(SentryScope * _Nonnull scope) {
        SentryUser *user = [[SentryUser alloc] initWithUserId: ...];
        [scope setUser:user];
    }];
   
    if (...) {
        NSError *e = [NSError errorWithDomain:@"..."
                                         code:1002
                                     userInfo:@{NSLocalizedDescriptionKey: @"Big error, show alert"}];
        [SentrySDK captureError:e];
        [self showMyAlert];
        return;
    }
    ...

Crash happens on the captureError: line.
Sentry version: sentry-cocoa 7.4.6
Happened also on previous versions.

Any idea why is this happening and how to prevent it? Thanks in advance.

Sorry but I believe you meant to add the line number after:

Crash happens on the captureError: line.

From the stack trace you shared I don’t see it going into SentrySDK

I could not reproduce the error with the giving sample.

Which line exactly is throwing the error?

Regards