`[SentryTransactionContext getThreadInfo]` causes EXC_BAD_ACCESS - `getThreadInfo` attempted to dereference null pointer
Platform
macOS
Operating system: macOS 11.7.8(20G1351)
Model: MacBookPro11,3 (Intel)
Installed
Swift Package Manager
Version
8.9.4
Steps to Reproduce
- Use SentrySDK v8.9.4 in macOS application
- Initialise SentrySDK
- Call
SentrySDK.startTransaction()(on main thread) - The application may crash with
EXC_BAD_ACCESS - getThreadInfo > attempted to dereference null pointer
SentrySDK.startTransaction(
name: "InstallFlow",
operation: #function,
bindToScope: true
)
Expected Result
Application should not crash.
Actual Result
sentry::profiling::ThreadHandle::current() (in Acme) (SentryThreadHandle.cpp:49)
-[SentryTransactionContext getThreadInfo] (in Acme) (SentryTransactionContext.mm:127)
-[SentryTransactionContext commonInitWithName:source:parentSampled:] (in Acme) (SentryTransactionContext.mm:147)
-[SentryTransactionContext initWithName:nameSource:operation:origin:] (in Acme) (SentryTransactionContext.mm:64)
-[SentryHub startTransactionWithName:operation:bindToScope:] (in Acme) (SentryHub.m:323)
+[SentrySDK startTransactionWithName:operation:bindToScope:] (in Acme) (SentrySDK.m:200)
InstallFlow.start() (in Acme) (InstallFlow.swift:22)
Are you willing to submit a PR?
No response
Across 65 devices we saw this crash only on single Intel based MacBook.
More information from the crash log:
System Integrity Protection: enabled
Notes: Translocated Process
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [26547]
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 ??? 000000000000000000 0 + 0
1 com.acme.AcmeApp 0x000000010fbd3f65 0x10faf3000 + 921445 // sentry::profiling::ThreadHandle::current() (in Acme) (SentryThreadHandle.cpp:49)
2 com.acme.AcmeApp 0x000000010fbdc149 0x10faf3000 + 954697 // -[SentryTransactionContext getThreadInfo] (in Acme) (SentryTransactionContext.mm:127)
3 com.acme.AcmeApp 0x000000010fbdc2ac 0x10faf3000 + 955052 // -[SentryTransactionContext commonInitWithName:source:parentSampled:] (in Acme) (SentryTransactionContext.mm:147)
4 com.acme.AcmeApp 0x000000010fbdbce9 0x10faf3000 + 953577 // -[SentryTransactionContext initWithName:nameSource:operation:origin:] (in Acme) (SentryTransactionContext.mm:64)
5 com.acme.AcmeApp 0x000000010fba626d 0x10faf3000 + 733805 // -[SentryHub startTransactionWithName:operation:bindToScope:] (in Acme) (SentryHub.m:323)
6 com.acme.AcmeApp 0x000000010fbc4710 0x10faf3000 + 857872 // +[SentrySDK startTransactionWithName:operation:bindToScope:] (in Acme) (SentrySDK.m:200)
7 com.acme.AcmeApp 0x000000010fb03295 0x10faf3000 + 66197 // InstallFlow.start() (in Acme) (InstallFlow.swift:22)
8 libswift_Concurrency.dylib 0x000000010ff01286 swift::runJobInEstablishedExecutorContext(swift::Job*) + 70
9 libswift_Concurrency.dylib 0x000000010ff01c7d swift_job_runImpl(swift::Job*, swift::ExecutorRef) + 77
10 libdispatch.dylib 0x00007fff2076d806 _dispatch_client_callout + 8
11 libdispatch.dylib 0x00007fff20779b4f _dispatch_main_queue_callback_4CF + 940
12 com.apple.CoreFoundation 0x00007fff20a4c8d8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
13 com.apple.CoreFoundation 0x00007fff20a0eb32 __CFRunLoopRun + 2755
14 com.apple.CoreFoundation 0x00007fff20a0d9ac CFRunLoopRunSpecific + 563
15 com.apple.HIToolbox 0x00007fff28c591f3 RunCurrentEventLoopInMode + 292
16 com.apple.HIToolbox 0x00007fff28c58f55 ReceiveNextEventCommon + 587
17 com.apple.HIToolbox 0x00007fff28c58cf3 _BlockUntilNextEventMatchingListInModeWithFilter + 70
18 com.apple.AppKit 0x00007fff23217ad2 _DPSNextEvent + 864
19 com.apple.AppKit 0x00007fff232162a5 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1364
20 com.apple.AppKit 0x00007fff232085c9 -[NSApplication run] + 586
21 com.apple.AppKit 0x00007fff231dc7cc NSApplicationMain + 816
22 com.acme.AcmeApp 0x000000010fb171bc 0x10faf3000 + 147900
23 libdyld.dylib 0x00007fff20932f3d start + 1
Thread 7:: SentryCrash Exception Handler (Secondary)
0 libsystem_kernel.dylib 0x00007fff208e229a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff208e260c mach_msg + 60
2 com.acme.AcmeApp 0x000000010fbe1386 0x10faf3000 + 975750
3 libsystem_pthread.dylib 0x00007fff209178fc _pthread_start + 224
4 libsystem_pthread.dylib 0x00007fff20913443 thread_start + 15
Thread 8:: com.apple.NSURLConnectionLoader
0 libsystem_kernel.dylib 0x00007fff208e229a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff208e260c mach_msg + 60
2 com.apple.CoreFoundation 0x00007fff20a0febf __CFRunLoopServiceMachPort + 316
3 com.apple.CoreFoundation 0x00007fff20a0e59f __CFRunLoopRun + 1328
4 com.apple.CoreFoundation 0x00007fff20a0d9ac CFRunLoopRunSpecific + 563
5 com.apple.CFNetwork 0x00007fff24eb9130 0x7fff24c78000 + 2363696
6 com.apple.Foundation 0x00007fff21799487 __NSThread__start__ + 1068
7 libsystem_pthread.dylib 0x00007fff209178fc _pthread_start + 224
8 libsystem_pthread.dylib 0x00007fff20913443 thread_start + 15
Thread 9:: io.sentry.app-hang-tracker
0 libsystem_kernel.dylib 0x00007fff208e4b92 __semwait_signal + 10
1 libsystem_c.dylib 0x00007fff20864c1a nanosleep + 196
2 com.apple.Foundation 0x00007fff2182cbc8 +[NSThread sleepForTimeInterval:] + 170
3 com.acme.AcmeApp 0x000000010fb7b541 0x10faf3000 + 558401
4 com.apple.Foundation 0x00007fff21799487 __NSThread__start__ + 1068
5 libsystem_pthread.dylib 0x00007fff209178fc _pthread_start + 224
6 libsystem_pthread.dylib 0x00007fff20913443 thread_start + 15
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x00007ffee010b0a8 rcx: 0x00007fff208e220a rdx: 0x0000000000000000
rdi: 0x0000000000000010 rsi: 0x0000000000000103 rbp: 0x00007ffee010b090 rsp: 0x00007ffee010b068
r8: 0x0000000000000000 r9: 0x00000000000000a0 r10: 0x00007fff208e2276 r11: 0x0000000000000206
r12: 0x00007ffee010b0a8 r13: 0x00006000028779c0 r14: 0x0000000000000103 r15: 0x0000000000000000
rip: 0x0000000000000000 rfl: 0x0000000000010246 cr2: 0x0000000000000000
Logical CPU: 4
Error Code: 0x00000014 (no mapping for user instruction read)
Trap Number: 14
Thread 0 instruction stream not available.
Thread 0 last branch register state not available.
Thanks for reporting @jozefizso, we'll investigate. (Internal reference.)
@jozefizso Are these macs that are under your control and could be used to test a patch? We have a potential workaround in https://github.com/getsentry/sentry-cocoa/pull/3364.
@armcknight We can contact the customer from our private beta program and try to have UX call to test it out.
This happened to our private beta customer. We will try to contact them to test the fix.
We've merged the PR, I'll ping back here when we generate the next release with the patch.
Thanks a lot @armcknight. 🎆
The fix was released with 8.15.0.
We had a UX call with a customer who had crash with Sentry v8.9.4.
System info:
macOS 11.3.1 (20E241)
Apple M1 (proc 8:4:4 processors)
8 GB
Stacktrace:
-[SentryTransactionContext getThreadInfo] (in Acme) (SentryTransactionContext.mm:127)
-[SentryTransactionContext commonInitWithName:source:parentSampled:] (in Acme) (SentryTransactionContext.mm:147)
-[SentryTransactionContext initWithName:nameSource:operation:origin:] (in Acme) (SentryTransactionContext.mm:64)
-[SentryHub startTransactionWithName:operation:bindToScope:] (in Acme) (SentryHub.m:323)
+[SentrySDK startTransactionWithName:operation:bindToScope:] (in Acme) (SentrySDK.m:200)
InstallFlow.start() (in Acme) (InstallFlow.swift:22)
Crashlog info:
System Integrity Protection: enabled
Notes: Translocated Process
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [15739]
VM Regions Near 0:
-->
__TEXT 1041a4000-104468000 [ 2832K] r-x/r-x SM=COW /var/folders/*/Acme.app/Contents/MacOS/Acme
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 ??? 000000000000000000 0 + 0
1 com.acme.AcmeApp 0x000000010426e40c 0x1041a4000 + 828428 // -[SentryTransactionContext getThreadInfo] (in Acme) (SentryTransactionContext.mm:127)
2 com.acme.AcmeApp 0x000000010426e544 0x1041a4000 + 828740 // -[SentryTransactionContext commonInitWithName:source:parentSampled:] (in Acme) (SentryTransactionContext.mm:147)
3 com.acme.AcmeApp 0x000000010426df58 0x1041a4000 + 827224 // -[SentryTransactionContext initWithName:nameSource:operation:origin:] (in Acme) (SentryTransactionContext.mm:64)
4 com.acme.AcmeApp 0x0000000104241584 0x1041a4000 + 644484 // -[SentryHub startTransactionWithName:operation:bindToScope:] (in Acme) (SentryHub.m:323)
5 com.acme.AcmeApp 0x000000010425a690 0x1041a4000 + 747152 // +[SentrySDK startTransactionWithName:operation:bindToScope:] (in Acme) (SentrySDK.m:200)
6 com.acme.AcmeApp 0x00000001041b3808 0x1041a4000 + 63496 // InstallFlow.start() (in Acme) (InstallFlow.swift:22)
7 libswift_Concurrency.dylib 0x000000010458a4cc swift::runJobInEstablishedExecutorContext(swift::Job*) + 156
8 libswift_Concurrency.dylib 0x000000010458ae04 swift_job_runImpl(swift::Job*, swift::ExecutorRef) + 80
9 libdispatch.dylib 0x000000019fe23e90 _dispatch_client_callout + 20
10 libdispatch.dylib 0x000000019fe322e4 _dispatch_main_queue_callback_4CF + 884
11 com.apple.CoreFoundation 0x00000001a0111e74 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
12 com.apple.CoreFoundation 0x00000001a00d0888 __CFRunLoopRun + 2524
13 com.apple.CoreFoundation 0x00000001a00cf734 CFRunLoopRunSpecific + 600
14 com.apple.HIToolbox 0x00000001a7fcdb84 RunCurrentEventLoopInMode + 292
15 com.apple.HIToolbox 0x00000001a7fcd810 ReceiveNextEventCommon + 320
16 com.apple.HIToolbox 0x00000001a7fcd6b8 _BlockUntilNextEventMatchingListInModeWithFilter + 72
17 com.apple.AppKit 0x00000001a28b94ec _DPSNextEvent + 836
18 com.apple.AppKit 0x00000001a28b7e8c -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1292
19 com.apple.AppKit 0x00000001a28a9d18 -[NSApplication run] + 596
20 com.apple.AppKit 0x00000001a287b728 NSApplicationMain + 1064
21 com.acme.AcmeApp 0x00000001041c5ad0 0x1041a4000 + 137936
22 libdyld.dylib 0x000000019fff0420 start + 4
@jozefizso, as pointed out above, this should be fixed with 8.15.0.
HI @philipphofmann, we tested the app with Sentry 8.15.2 and we still see crashes on some systems.
We have a MacBook where our app will crash. We tested with different macOS releases on that hardware and it did not fix the issue.
Stacktrace:
sentry::profiling::ThreadHandle::current() (in AcmeApp) (SentryThreadHandle.cpp:48)
-[SentryTransactionContext getThreadInfo] (in AcmeApp) (SentryTransactionContext.mm:127)
-[SentryTransactionContext commonInitWithName:source:parentSampled:] (in AcmeApp) (SentryTransactionContext.mm:147)
-[SentryTransactionContext initWithName:nameSource:operation:origin:] (in AcmeApp) (SentryTransactionContext.mm:64)
-[SentryHub startTransactionWithName:operation:bindToScope:] (in AcmeApp) (SentryHub.m:323)
+[SentrySDK startTransactionWithName:operation:bindToScope:] (in AcmeApp) (SentrySDK.m:216)
PreInstallFlow.start() (in AcmeApp) (PreInstallFlow.swift:16)
System info 1 (macOS 11.2.1 (20D75)):
Date/Time: 2023-11-22 10:06:17.092 +0100
OS Version: macOS 11.2.1 (20D75)
Report Version: 12
Bridge OS Version: 5.2 (18P4346)
Anonymous UUID: 66597CD1-136E-762E-2DB4-ED1D645BA4F0
Sleep/Wake UUID: AD86D89C-F025-4E02-9B6D-5729603CB990
Time Awake Since Boot: 270000 seconds
Time Since Wake: 5000000 seconds
System Integrity Protection: enabled
Notes: Translocated Process
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [49263]
VM Regions Near 0:
-->
__TEXT 10ab1c000-10ae24000 [ 3104K] r-x/r-x SM=COW /var/folders/*/AcmeApp.app/Contents/MacOS/AcmeApp
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 ??? 000000000000000000 0 + 0
1 com.acme.AcmeApp 0x000000010ac19a3a 0x10ab1c000 + 1038906
2 com.acme.AcmeApp 0x000000010ac22427 0x10ab1c000 + 1074215
3 com.acme.AcmeApp 0x000000010ac2258a 0x10ab1c000 + 1074570
4 com.acme.AcmeApp 0x000000010ac21fc7 0x10ab1c000 + 1073095
5 com.acme.AcmeApp 0x000000010abea2b2 0x10ab1c000 + 844466
6 com.acme.AcmeApp 0x000000010ac0a736 0x10ab1c000 + 976694
7 com.acme.AcmeApp 0x000000010ab4b4ce 0x10ab1c000 + 193742
8 libswift_Concurrency.dylib 0x000000010afb9286 swift::runJobInEstablishedExecutorContext(swift::Job*) + 70
9 libswift_Concurrency.dylib 0x000000010afb9c7d swift_job_runImpl(swift::Job*, swift::ExecutorRef) + 77
10 libdispatch.dylib 0x00007fff204387c7 _dispatch_client_callout + 8
11 libdispatch.dylib 0x00007fff20444b86 _dispatch_main_queue_callback_4CF + 940
12 com.apple.CoreFoundation 0x00007fff20718970 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
13 com.apple.CoreFoundation 0x00007fff206da852 __CFRunLoopRun + 2731
14 com.apple.CoreFoundation 0x00007fff206d96ce CFRunLoopRunSpecific + 563
15 com.apple.HIToolbox 0x00007fff28961630 RunCurrentEventLoopInMode + 292
16 com.apple.HIToolbox 0x00007fff28961282 ReceiveNextEventCommon + 283
17 com.apple.HIToolbox 0x00007fff2896114f _BlockUntilNextEventMatchingListInModeWithFilter + 64
18 com.apple.AppKit 0x00007fff22ef99b1 _DPSNextEvent + 883
19 com.apple.AppKit 0x00007fff22ef8177 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1366
20 com.apple.AppKit 0x00007fff22eea68a -[NSApplication run] + 586
21 com.apple.AppKit 0x00007fff22ebe96f NSApplicationMain + 816
22 com.acme.AcmeApp 0x000000010ab5186c 0x10ab1c000 + 219244
23 libdyld.dylib 0x00007fff205fe621 start + 1
System info 2 (macOS 11.7.10 (20G1427)):
Date/Time: 2023-11-22 12:05:14.654 +0100
OS Version: macOS 11.7.10 (20G1427)
Report Version: 12
Bridge OS Version: 8.1 (21P1069)
Anonymous UUID: C548BCC6-5DB1-41DC-BBC4-1CF96528685B
Time Awake Since Boot: 130 seconds
System Integrity Protection: enabled
Notes: Translocated Process
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [675]
VM Regions Near 0:
-->
__TEXT 107762000-107a6a000 [ 3104K] r-x/r-x SM=COW /var/folders/*/AcmeApp.app/Contents/MacOS/AcmeApp
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 ??? 000000000000000000 0 + 0
1 com.acme.AcmeApp 0x000000010785fa3a 0x107762000 + 1038906
2 com.acme.AcmeApp 0x0000000107868427 0x107762000 + 1074215
3 com.acme.AcmeApp 0x000000010786858a 0x107762000 + 1074570
4 com.acme.AcmeApp 0x0000000107867fc7 0x107762000 + 1073095
5 com.acme.AcmeApp 0x00000001078302b2 0x107762000 + 844466
6 com.acme.AcmeApp 0x0000000107850736 0x107762000 + 976694
7 com.acme.AcmeApp 0x00000001077914ce 0x107762000 + 193742
8 libswift_Concurrency.dylib 0x0000000107bfc286 swift::runJobInEstablishedExecutorContext(swift::Job*) + 70
9 libswift_Concurrency.dylib 0x0000000107bfcc7d swift_job_runImpl(swift::Job*, swift::ExecutorRef) + 77
10 libdispatch.dylib 0x00007fff20642806 _dispatch_client_callout + 8
11 libdispatch.dylib 0x00007fff2064eb4f _dispatch_main_queue_callback_4CF + 940
12 com.apple.CoreFoundation 0x00007fff209218d8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
13 com.apple.CoreFoundation 0x00007fff208e3b32 __CFRunLoopRun + 2755
14 com.apple.CoreFoundation 0x00007fff208e29ac CFRunLoopRunSpecific + 563
15 com.apple.HIToolbox 0x00007fff28b2d1f3 RunCurrentEventLoopInMode + 292
16 com.apple.HIToolbox 0x00007fff28b2ce26 ReceiveNextEventCommon + 284
17 com.apple.HIToolbox 0x00007fff28b2ccf3 _BlockUntilNextEventMatchingListInModeWithFilter + 70
18 com.apple.AppKit 0x00007fff230ecad2 _DPSNextEvent + 864
19 com.apple.AppKit 0x00007fff230eb2a5 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1364
20 com.apple.AppKit 0x00007fff230dd5c9 -[NSApplication run] + 586
21 com.apple.AppKit 0x00007fff230b17cc NSApplicationMain + 816
22 com.acme.AcmeApp 0x000000010779786c 0x107762000 + 219244
23 libdyld.dylib 0x00007fff20807f3d start + 1
@armcknight, do you have any ideas on why SentryTransactionContext getThreadInfo could crash with an EXC_BAD_ACCESS? Once crash points to sentry::profiling::ThreadHandle::current().
PS: Some of the customers affected by the crash in the release which used the 8.9.4 sentry told us this crash was fixed for them. We see this crash on our own laptop now so we can check&verify it more easily.
Sounds like we were able to fix a subset of the cases 🎉 but there's still another issue. Looking again at the exception code, it mentions a null address. I should've inserted a null check on the value returned by pthread_mach_thread_np. Beyond that, we have no control over what that kernel call returns, so if it's a null value we need to just try to gracefully fail instead of crashing.
@jozefizso are you able to validate the branch in the linked pull request (#3443)?
Hi @armcknight, we have another test MacBook available where our app crashes with the 8.15.2.
I compiled our app with the #3443 as SPM reference and still got the crash:
-[SentryTransactionContext getThreadInfo] (in AcmeApp) (SentryTransactionContext.mm:130)
sentry::profiling::ThreadHandle::current() (in AcmeApp) (SentryThreadHandle.cpp:51)
-[SentryTransactionContext commonInitWithName:source:parentSampled:] (in AcmeApp) (SentryTransactionContext.mm:155)
-[SentryTransactionContext initWithName:nameSource:operation:origin:] (in AcmeApp) (SentryTransactionContext.mm:64)
-[SentryHub startTransactionWithName:operation:bindToScope:] (in AcmeApp) (SentryHub.m:329)
+[SentrySDK startTransactionWithName:operation:bindToScope:] (in AcmeApp) (SentrySDK.m:216)
PreInstallFlow.start() (in AcmeApp) (PreInstallFlow.swift:16)
https://github.com/getsentry/sentry-cocoa/blob/armcknight/fix/3354-nilcheck/Sources/Sentry/SentryTransactionContext.mm#L130
https://github.com/getsentry/sentry-cocoa/blob/armcknight/fix/3354-nilcheck/Sources/Sentry/SentryThreadHandle.cpp#L51
Model: MacBookPro16,1, BootROM 2020.0.1.0.0 (iBridge: 21.16.365.0.0,0), 6 processors, 6-Core Intel Core i7, 2,6 GHz, 16 GB, SMC
Graphics: kHW_IntelUHDGraphics630Item, Intel UHD Graphics 630, spdisplays_builtin
Crash info:
Date/Time: 2023-11-23 06:07:44.786 -0800
OS Version: macOS 11.7.10 (20G1427)
Report Version: 12
Bridge OS Version: 8.0 (21P365)
Anonymous UUID: A576B358-0167-42B4-A18B-8A72AC8E16A0
Sleep/Wake UUID: 2F2CADF0-6E56-42CB-9E54-F41F1D0DC8BE
Time Awake Since Boot: 3200 seconds
Time Since Wake: 740 seconds
System Integrity Protection: enabled
Notes: Translocated Process
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [2800]
I tried it on the same system but on macOS 12 partition and sentry works there.
Thanks for responding @jozefizso , we're investigating further.
Hi, is there an update about this issue? Our app is currently unusable on macOS 11 because of this.
We don't currently have another lead on this, we're planning to take another look at it next week. Sorry for the delay!
Are you able to describe what's going on in your repro case at the time this crashes, if there's something reliably reproducing it? Are you using other threads, or creating/destroying many? Are you starting/stopping a manual transaction from main/other thread, or is this from automatic instrumentation?
When I compile the app and sentry-cocoa with disabled optimizations, I get this stack trace:
std::__1::__unique_if<sentry::profiling::ThreadHandle>::__unique_single std::__1::make_unique[abi:v160006]<sentry::profiling::ThreadHandle, unsigned int const&>(unsigned int const&) (in Slido) (unique_ptr.h:686)
sentry::profiling::ThreadHandle::current() (in Slido) (SentryThreadHandle.cpp:51)
-[SentryTransactionContext getThreadInfo] (in Slido) (SentryTransactionContext.mm:130)
-[SentryTransactionContext commonInitWithName:source:parentSampled:] (in Slido) (SentryTransactionContext.mm:153)
-[SentryTransactionContext initWithName:nameSource:operation:origin:] (in Slido) (SentryTransactionContext.mm:61)
-[SentryHub startTransactionWithName:operation:bindToScope:] (in Slido) (SentryHub.m:329)
+[SentrySDK startTransactionWithName:operation:bindToScope:] (in Slido) (SentrySDK.m:217)
PreInstallFlow.start() (in Slido) (PreInstallFlow.swift:16)
The app will call SentrySDK.start() in the NSApplicationDelegate.applicationDidFinishLaunching() method.
We will create content view and show it in a new NSWindow. App will determine the flow (eg. installation, uninstallation, normal run of the app) and each flow will start transaction using SentrySDK.startTransaction().
Roughly:
@main
final class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ aNotification: Notification) {
SentrySDK.start { options in options.dsn = "DSN" }
// create content view and NSWindow...
self.appFlow = PreInstallFlow(
appState: self.appState,
buildInfo: buildInfo
)
Task { @MainActor in
await self.appFlow?.start()
}
}
}
struct PreInstallFlow: AppFlow {
func start() async {
SentrySDK.startTransaction(
name: "PreInstallFlow",
operation: #function,
bindToScope: true
)
}
}
When I changed the code and put the SentrySDK.startTransaction() directly to the applicationDidFinishLaunching() I got the crash too:
std::__1::__unique_if<sentry::profiling::ThreadHandle>::__unique_single std::__1::make_unique[abi:v160006]<sentry::profiling::ThreadHandle, unsigned int const&>(unsigned int const&) (in Slido) (unique_ptr.h:686)
sentry::profiling::ThreadHandle::current() (in Slido) (SentryThreadHandle.cpp:51)
-[SentryTransactionContext getThreadInfo] (in Slido) (SentryTransactionContext.mm:130)
-[SentryTransactionContext commonInitWithName:source:parentSampled:] (in Slido) (SentryTransactionContext.mm:153)
-[SentryTransactionContext initWithName:nameSource:operation:origin:] (in Slido) (SentryTransactionContext.mm:61)
-[SentryHub startTransactionWithName:operation:] (in Slido) (SentryHub.m:318)
+[SentrySDK startTransactionWithName:operation:] (in Slido) (SentrySDK.m:210)
AppDelegate.applicationDidFinishLaunching(_:) (in Slido) (AppDelegate.swift:115)
@objc AppDelegate.applicationDidFinishLaunching(_:) (in Slido) (<compiler-generated>:0)
Thanks for the additional information @jozefizso . I'm not sure it's actually because of async/await and actors, but good to know more ways to look at this.