getsentry / sentry-cocoa

The official Sentry SDK for iOS, tvOS, macOS, watchOS.
https://sentry.io/for/cocoa/
MIT License
815 stars 330 forks source link

-[SentrySpan setDataValue:forKey:] SIGTRAP #3675

Open kvdesa opened 9 months ago

kvdesa commented 9 months ago

Platform

iOS

Environment

Production

Installed

Swift Package Manager

Version

8.20.0

Did it work on previous versions?

8.9.4

Steps to Reproduce

After updating from 8.9.4 to 8.20.0, we saw a significant increase in this crash. It already occurred when using the previous version, but at a smaller rate. Now, we are considering reverting to the old version if this persists. After a quick search, I found this issue that was fixed in 8.15.2, I don't know if it's related.

Crash Report OS Version: iOS 17.2.1 (21C66) Report Version: 104 Exception Type: EXC_BREAKPOINT (SIGTRAP) Crashed Thread: 0 Application Specific Information: Exception 6, Code 1, Subcode 8944013932 Thread 0 Crashed: 0 libsystem_platform.dylib 0x406eb826c _os_unfair_lock_corruption_abort 1 libsystem_platform.dylib 0x406eb5354 _os_unfair_lock_lock_slow 2 libobjc.A.dylib 0x3236744b0 objc_sync_enter 3 Mimo 0x2013a66b0 -[SentrySpan setDataValue:forKey:] (SentrySpan.m:129) 4 Mimo 0x2013a6e60 -[SentrySpan finishWithStatus:] (SentrySpan.m:217) 5 Mimo 0x2013afdbc -[SentryTracer deadlineTimerFired] (SentryTracer.m:277) 6 Mimo 0x2013afb28 __34-[SentryTracer startDeadlineTimer]_block_invoke_2 (SentryTracer.m:259) 7 Foundation 0x33163bd88 __NSFireTimer 8 CoreFoundation 0x33306d3e8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ 9 CoreFoundation 0x33306d090 __CFRunLoopDoTimer 10 CoreFoundation 0x332ff6c80 __CFRunLoopDoTimers 11 CoreFoundation 0x332ff3c98 __CFRunLoopRun 12 CoreFoundation 0x332ff3474 CFRunLoopRunSpecific 13 GraphicsServices 0x3b9b254f4 GSEventRunModal 14 UIKitCore 0x337642628 -[UIApplication _run] 15 UIKitCore 0x337641c64 UIApplicationMain 16 Mimo 0x2009dcaf8 main (main.swift:16) 17 0x1cdf9adcc Thread 0 Crashed: 0 libsystem_platform.dylib 0x406eb826c _os_unfair_lock_corruption_abort 1 libsystem_platform.dylib 0x406eb5354 _os_unfair_lock_lock_slow 2 libobjc.A.dylib 0x3236744b0 objc_sync_enter 3 Mimo 0x2013a66b0 -[SentrySpan setDataValue:forKey:] (SentrySpan.m:129) 4 Mimo 0x2013a6e60 -[SentrySpan finishWithStatus:] (SentrySpan.m:217) 5 Mimo 0x2013afdbc -[SentryTracer deadlineTimerFired] (SentryTracer.m:277) 6 Mimo 0x2013afb28 __34-[SentryTracer startDeadlineTimer]_block_invoke_2 (SentryTracer.m:259) 7 Foundation 0x33163bd88 __NSFireTimer 8 CoreFoundation 0x33306d3e8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ 9 CoreFoundation 0x33306d090 __CFRunLoopDoTimer 10 CoreFoundation 0x332ff6c80 __CFRunLoopDoTimers 11 CoreFoundation 0x332ff3c98 __CFRunLoopRun 12 CoreFoundation 0x332ff3474 CFRunLoopRunSpecific 13 GraphicsServices 0x3b9b254f4 GSEventRunModal 14 UIKitCore 0x337642628 -[UIApplication _run] 15 UIKitCore 0x337641c64 UIApplicationMain 16 Mimo 0x2009dcaf8 main (main.swift:16) 17 0x1cdf9adcc Thread 1 0 libsystem_kernel.dylib 0x3c1e856d0 __workq_kernreturn 1 libsystem_pthread.dylib 0x4070099ac _pthread_wqthread Thread 2 0 libsystem_kernel.dylib 0x3c1e856d0 __workq_kernreturn 1 libsystem_pthread.dylib 0x4070099ac _pthread_wqthread Thread 3 name: com.apple.uikit.eventfetch-thread 0 libsystem_kernel.dylib 0x3c1e7d178 mach_msg2_trap 1 libsystem_kernel.dylib 0x3c1e7cf0c mach_msg2_internal 2 libsystem_kernel.dylib 0x3c1e7ce24 mach_msg_overwrite 3 libsystem_kernel.dylib 0x3c1e7cc64 mach_msg 4 CoreFoundation 0x332ff5b18 __CFRunLoopServiceMachPort 5 CoreFoundation 0x332ff3a10 __CFRunLoopRun 6 CoreFoundation 0x332ff3474 CFRunLoopRunSpecific 7 Foundation 0x330f20488 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] 8 Foundation 0x330f4d748 -[NSRunLoop(NSRunLoop) runUntilDate:] 9 UIKitCore 0x3375a44a4 -[UIEventFetcher threadMain] 10 Foundation 0x330fa3ddc __NSThread__start__ 11 libsystem_pthread.dylib 0x40700a4d0 _pthread_start Thread 4 0 libsystem_kernel.dylib 0x3c1e7dbf8 __ulock_wait 1 libsystem_platform.dylib 0x406eb52d8 _os_unfair_lock_lock_slow 2 libobjc.A.dylib 0x3236744b0 objc_sync_enter 3 Mimo 0x2013a66b0 -[SentrySpan setDataValue:forKey:] (SentrySpan.m:129) 4 Mimo 0x20138cb28 __45-[SentryNetworkTracker urlSessionTaskResume:]_block_invoke (SentryNetworkTracker.m:183) 5 Mimo 0x20139f2fc -[SentryScope useSpan:] (SentryScope.m:148) 6 Mimo 0x20138c61c -[SentryNetworkTracker urlSessionTaskResume:] (SentryNetworkTracker.m:173) 7 Mimo 0x20138ed74 __57+[SentryNetworkTrackingIntegration swizzleURLSessionTask]_block_invoke_2 (SentryNetworkTrackingIntegration.m:65) 8 Mimo 0x20152fe2c Session.updateStatesForTask (Session.swift:1130) 9 Mimo 0x20152fd48 [inlined] Protected.withState (Protected.swift:159) 10 Mimo 0x20152fd48 [inlined] Lock.around (Protected.swift:48) 11 Mimo 0x20152fd48 [inlined] Protected.withState (Protected.swift:159) 12 Mimo 0x20152fd48 [inlined] Request.withState (Request.swift:643) 13 Mimo 0x20152fd48 Session.updateStatesForTask (Session.swift:1124) 14 Mimo 0x20152fa00 Session.didCreateURLRequest (Session.swift:1106) 15 Mimo 0x20153d9ec Session.performSetupOperations 16 Mimo 0x2014bb0f8 thunk for closure 17 libdispatch.dylib 0x342fa86a4 _dispatch_call_block_and_release 18 libdispatch.dylib 0x342faa2fc _dispatch_client_callout 19 libdispatch.dylib 0x342fb1890 _dispatch_lane_serial_drain 20 libdispatch.dylib 0x342fb23f4 _dispatch_lane_invoke 21 libdispatch.dylib 0x342fb1714 _dispatch_lane_serial_drain 22 libdispatch.dylib 0x342fb23c0 _dispatch_lane_invoke 23 libdispatch.dylib 0x342fbd000 _dispatch_root_queue_drain_deferred_wlh 24 libdispatch.dylib 0x342fbc874 _dispatch_workloop_worker_thread 25 libsystem_pthread.dylib 0x407009960 _pthread_wqthread Thread 5 0 libsystem_kernel.dylib 0x3c1e7d978 __semwait_signal 1 libsystem_c.dylib 0x34303df1c nanosleep 2 libsystem_c.dylib 0x34304c1d8 sleep 3 Mimo 0x2013c6830 monitorCachedData (SentryCrashCachedData.c:145) 4 libsystem_pthread.dylib 0x40700a4d0 _pthread_start Thread 6 name: SentryCrash Exception Handler (Secondary) 0 libsystem_kernel.dylib 0x3c1e7d178 mach_msg2_trap 1 libsystem_kernel.dylib 0x3c1e7cf0c mach_msg2_internal 2 libsystem_kernel.dylib 0x3c1e7ce24 mach_msg_overwrite 3 libsystem_kernel.dylib 0x3c1e7cc64 mach_msg 4 Mimo 0x2013c265c handleExceptions (SentryCrashMonitor_MachException.c:314) 5 libsystem_pthread.dylib 0x40700a4d0 _pthread_start Thread 8 name: com.apple.NSURLConnectionLoader 0 libsystem_kernel.dylib 0x3c1e7d178 mach_msg2_trap 1 libsystem_kernel.dylib 0x3c1e7cf0c mach_msg2_internal 2 libsystem_kernel.dylib 0x3c1e7ce24 mach_msg_overwrite 3 libsystem_kernel.dylib 0x3c1e7cc64 mach_msg 4 CoreFoundation 0x332ff5b18 __CFRunLoopServiceMachPort 5 CoreFoundation 0x332ff3a10 __CFRunLoopRun 6 CoreFoundation 0x332ff3474 CFRunLoopRunSpecific 7 CFNetwork 0x3353c805c estimatedPropertyListSize 8 Foundation 0x330fa3ddc __NSThread__start__ 9 libsystem_pthread.dylib 0x40700a4d0 _pthread_start Thread 9 0 libsystem_kernel.dylib 0x3c1e856d0 __workq_kernreturn 1 libsystem_pthread.dylib 0x4070099ac _pthread_wqthread Thread 10 0 libsystem_pthread.dylib 0x4070099fc start_wqthread Thread 11 0 libsystem_kernel.dylib 0x3c1e856d0 __workq_kernreturn 1 libsystem_pthread.dylib 0x4070099ac _pthread_wqthread Thread 12 0 libsystem_kernel.dylib 0x3c1e7d178 mach_msg2_trap 1 libsystem_kernel.dylib 0x3c1e7cf0c mach_msg2_internal 2 libsystem_kernel.dylib 0x3c1e7ce24 mach_msg_overwrite 3 libsystem_kernel.dylib 0x3c1e7cc64 mach_msg 4 CoreFoundation 0x332ff5b18 __CFRunLoopServiceMachPort 5 CoreFoundation 0x332ff3a10 __CFRunLoopRun 6 CoreFoundation 0x332ff3474 CFRunLoopRunSpecific 7 CoreFoundation 0x332ff31d8 CFRunLoopRun 8 CoreMotion 0x34cc6b618 CLClientGetDistanceCoordinates 9 libsystem_pthread.dylib 0x40700a4d0 _pthread_start Thread 0 crashed with ARM Thread State (64-bit): x0: 0x0000000000001902 x1: 0x0000000000000000 x2: 0x0000000000001902 x3: 0x0000000000000000 x4: 0x0000000000000002 x5: 0x0000000000003ee0 x6: 0x0000000000000022 x7: 0x0000000000000000 x8: 0x0000000000001902 x9: 0x0000000000001702 x10: 0x000000000003fe00 x11: 0xfffffffd7e8301f0 x12: 0x00000000008e2180 x13: 0x00000001038160f0 x14: 0x00000001fc4dd450 x15: 0x00000001fc4dd450 x16: 0x0000000000000203 x17: 0x03000001fc4dd8d9 x18: 0x0000000000000000 x19: 0x0000000000000103 x20: 0x0000000000000000 x21: 0x00000001037807d8 x22: 0x0000000001000002 x23: 0x0000000000001902 x24: 0x0000000000000000 x25: 0x00000000ffffffff x26: 0x0000000000000103 x27: 0x00000002822c4380 x28: 0x00000002819c3540 fp: 0x000000016f42e500 lr: 0x00000002151aa358 sp: 0x000000016f42e4c0 pc: 0x00000002151ad26c cpsr: 0x0000000080001000

Expected Result

Crash

Actual Result

No crash.

Are you willing to submit a PR?

No response

kahest commented 9 months ago

@kvdesa thank you for reporting this, we'll look into it!

Internal references: release 8.9.4, release 8.20.0

kvdesa commented 9 months ago

I don't know if it's related, but I just did a bit more digging and found out that the calls of our app, Mimo, in thread 4:

13 Mimo 0x20152fd48 Session.updateStatesForTask (Session.swift:1124)
14 Mimo 0x20152fa00 Session.didCreateURLRequest (Session.swift:1106)
15 Mimo 0x20153d9ec Session.performSetupOperations

that happen right before some Sentry related calls in the same thread:

3 Mimo 0x2013a66b0 -[SentrySpan setDataValue:forKey:] (SentrySpan.m:129)
4 Mimo 0x20138cb28 __45-[SentryNetworkTracker urlSessionTaskResume:]_block_invoke (SentryNetworkTracker.m:183)
5 Mimo 0x20139f2fc -[SentryScope useSpan:] (SentryScope.m:148)
6 Mimo 0x20138c61c -[SentryNetworkTracker urlSessionTaskResume:] (SentryNetworkTracker.m:173)
7 Mimo 0x20138ed74 __57+[SentryNetworkTrackingIntegration swizzleURLSessionTask]_block_invoke_2 (SentryNetworkTrackingIntegration.m:65)

are related to another dependency we have, RxAlamofire, which happened to be updated to the latest version together with Sentry, don't know if you had anything similar in the past.

We decided to revert both these changes and see if this fixes the issue.

kahest commented 9 months ago

@kvdesa thank you for the additional details, that's really helpful! Can you tell us the version(s) of RxAlamofire you use?

What you observe is our network tracking kicking in. In case reverting the versions doesn't work you can instead temporarily deactivate network tracking as shown in the docs linked above, while we work an a solution.

kvdesa commented 9 months ago

@kvdesa thank you for the additional details, that's really helpful! Can you tell us the version(s) of RxAlamofire you use?

The previous version of RxAlamofire, that we reverted back to, is 6.0.0 and the new version, that we upgraded together with Sentry's 8.20.0, is 6.1.2.