`SentrySDK.addBreadcrumb` crashes
Platform
macOS
Installed
Swift Package Manager
Version
7.31.2
Steps to Reproduce
I cannot reproduce. It's a crash report from a user.
Expected Result
I expected the Sentry SDK to never crash my app.
Actual Result
Crash log:
Also viewable at: https://sentry.io/organizations/sindresorhus/issues/3870221461/events/6fa32daaf73d409db9ee5ebe02d3f29c/
OS Version: macOS 13.1.0 (22C65)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: BUS_NOOP at 0x00000000deadbeef
Crashed Thread: 7
Application Specific Information:
isEqual: >
Attempted to dereference garbage pointer 0xdeadbeef.
Thread 7 Crashed:
0 libobjc.A.dylib 0x30b479808 objc_msgSend
1 CoreFoundation 0x30bc52f70 -[__NSDictionaryM setObject:forKey:]
2 Velja 0x204537d70 -[SentryBreadcrumb serialize] (SentryBreadcrumb.m:33)
3 Velja 0x2045382e0 -[SentryBreadcrumb description] (SentryBreadcrumb.m:85)
4 Foundation 0x30da7a288 _NSDescriptionWithLocaleFunc
5 CoreFoundation 0x30bc46d60 __CFStringAppendFormatCore
6 CoreFoundation 0x30bd84d1c _CFStringCreateWithFormatAndArgumentsReturningMetadata
7 CoreFoundation 0x30bc4420c _CFStringCreateWithFormatAndArgumentsAux2
8 Foundation 0x30da8857c +[NSString stringWithFormat:]
9 Velja 0x20456d994 -[SentryScope addBreadcrumb:] (SentryScope.m:129)
10 Velja 0x2045551f0 -[SentryHub addBreadcrumb:] (SentryHub.m:499)
11 Velja 0x20456bbc0 +[SentrySDK addBreadcrumb:] (SentrySDK.m:337)
12 Velja 0x204490860 SSApp.addBreadcrumb (SSKit.swift:36392)
13 Velja 0x20450a330 OpenController.openURLs
14 libswift_Concurrency.dylib 0x41e94a4c4 swift::runJobInEstablishedExecutorContext
Thread 0
0 libsystem_kernel.dylib 0x30badad70 mach_msg2_trap
1 libsystem_kernel.dylib 0x30baec8a4 mach_msg2_internal
2 libsystem_kernel.dylib 0x30bae35c4 mach_msg_overwrite
3 libsystem_kernel.dylib 0x30badb0ec mach_msg
4 CoreFoundation 0x30bc97bc0 __CFRunLoopServiceMachPort
5 CoreFoundation 0x30bc964ac __CFRunLoopRun
6 CoreFoundation 0x30bc95888 CFRunLoopRunSpecific
7 HIToolbox 0x31ea8dfa0 RunCurrentEventLoopInMode
8 HIToolbox 0x31ea8dde4 ReceiveNextEventCommon
9 HIToolbox 0x31ea8db2c _BlockUntilNextEventMatchingListInModeWithFilter
10 AppKit 0x3121df424 _DPSNextEvent
11 AppKit 0x3121de5b4 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
12 AppKit 0x3121d29e4 -[NSApplication run]
13 AppKit 0x3121a9e28 NSApplicationMain
14 SwiftUI 0x35938b8a8 OUTLINED_FUNCTION_8
15 SwiftUI 0x35a5407c0 OUTLINED_FUNCTION_11
16 SwiftUI 0x359d6483c OUTLINED_FUNCTION_1
17 Velja 0x2043a5bb4 [inlined] AppMain.$main (App.swift:125)
18 Velja 0x2043a5bb4 main
19 <unknown> 0x18b463e50 <redacted>
Thread 1
0 libsystem_kernel.dylib 0x30bade360 __semwait_signal
1 libsystem_c.dylib 0x30b8e85b0 nanosleep
2 libsystem_c.dylib 0x30b8f3128 sleep
3 Velja 0x204585e60 monitorCachedData (SentryCrashCachedData.c:144)
4 libsystem_pthread.dylib 0x30bb5306c _pthread_start
Thread 2 name: SentryCrash Exception Handler (Secondary)
0 libsystem_kernel.dylib 0x30badad70 mach_msg2_trap
1 libsystem_kernel.dylib 0x30baec8a4 mach_msg2_internal
2 libsystem_kernel.dylib 0x30bae35c4 mach_msg_overwrite
3 libsystem_kernel.dylib 0x30badb0ec mach_msg
4 Velja 0x204581c7c handleExceptions (SentryCrashMonitor_MachException.c:266)
5 libsystem_pthread.dylib 0x30bb5306c _pthread_start
Thread 4 name: io.sentry.app-hang-tracker
0 libsystem_kernel.dylib 0x30bade360 __semwait_signal
1 libsystem_c.dylib 0x30b8e85b0 nanosleep
2 Foundation 0x30db42364 +[NSThread sleepForTimeInterval:]
3 Velja 0x204533ff0 -[SentryANRTracker detectANRs] (SentryANRTracker.m:75)
4 Foundation 0x30dac4470 __NSThread__start__
5 libsystem_pthread.dylib 0x30bb5306c _pthread_start
Thread 5 name: com.apple.NSEventThread
0 libsystem_kernel.dylib 0x30badad70 mach_msg2_trap
1 libsystem_kernel.dylib 0x30baec8a4 mach_msg2_internal
2 libsystem_kernel.dylib 0x30bae35c4 mach_msg_overwrite
3 libsystem_kernel.dylib 0x30badb0ec mach_msg
4 CoreFoundation 0x30bc97bc0 __CFRunLoopServiceMachPort
5 CoreFoundation 0x30bc964ac __CFRunLoopRun
6 CoreFoundation 0x30bc95888 CFRunLoopRunSpecific
7 AppKit 0x312309410 _NSEventThread
8 libsystem_pthread.dylib 0x30bb5306c _pthread_start
Thread 6 name: com.apple.NSURLConnectionLoader
0 libsystem_kernel.dylib 0x30badad70 mach_msg2_trap
1 libsystem_kernel.dylib 0x30baec8a4 mach_msg2_internal
2 libsystem_kernel.dylib 0x30bae35c4 mach_msg_overwrite
3 libsystem_kernel.dylib 0x30badb0ec mach_msg
4 CoreFoundation 0x30bc97bc0 __CFRunLoopServiceMachPort
5 CoreFoundation 0x30bc964ac __CFRunLoopRun
6 CoreFoundation 0x30bc95888 CFRunLoopRunSpecific
7 CFNetwork 0x314eb5500 _CFURLStorageSessionDisableCache
8 Foundation 0x30dac4470 __NSThread__start__
9 libsystem_pthread.dylib 0x30bb5306c _pthread_start
Thread 7 Crashed:
0 libobjc.A.dylib 0x30b479808 objc_msgSend
1 CoreFoundation 0x30bc52f70 -[__NSDictionaryM setObject:forKey:]
2 Velja 0x204537d70 -[SentryBreadcrumb serialize] (SentryBreadcrumb.m:33)
3 Velja 0x2045382e0 -[SentryBreadcrumb description] (SentryBreadcrumb.m:85)
4 Foundation 0x30da7a288 _NSDescriptionWithLocaleFunc
5 CoreFoundation 0x30bc46d60 __CFStringAppendFormatCore
6 CoreFoundation 0x30bd84d1c _CFStringCreateWithFormatAndArgumentsReturningMetadata
7 CoreFoundation 0x30bc4420c _CFStringCreateWithFormatAndArgumentsAux2
8 Foundation 0x30da8857c +[NSString stringWithFormat:]
9 Velja 0x20456d994 -[SentryScope addBreadcrumb:] (SentryScope.m:129)
10 Velja 0x2045551f0 -[SentryHub addBreadcrumb:] (SentryHub.m:499)
11 Velja 0x20456bbc0 +[SentrySDK addBreadcrumb:] (SentrySDK.m:337)
12 Velja 0x204490860 SSApp.addBreadcrumb (SSKit.swift:36392)
13 Velja 0x20450a330 OpenController.openURLs
14 libswift_Concurrency.dylib 0x41e94a4c4 swift::runJobInEstablishedExecutorContext
Thread 8
0 libsystem_kernel.dylib 0x30badca1c __workq_kernreturn
1 libsystem_pthread.dylib 0x30bb4f14c _pthread_wqthread
Thread 9
0 libsystem_kernel.dylib 0x30badca1c __workq_kernreturn
1 libsystem_pthread.dylib 0x30bb4f14c _pthread_wqthread
Thread 10
0 libsystem_kernel.dylib 0x30badca1c __workq_kernreturn
1 libsystem_pthread.dylib 0x30bb4f14c _pthread_wqthread
Thread 11
0 libsystem_kernel.dylib 0x30badca1c __workq_kernreturn
1 libsystem_pthread.dylib 0x30bb4f14c _pthread_wqthread
Thread 12
0 CoreFoundation 0x30bc36a08 -[__NSArrayM insertObject:atIndex:]
1 Foundation 0x30dab8230 [inlined] addValueToTopContainerE
2 Foundation 0x30dab8230 addValueToTopContainerE
3 Foundation 0x30dab7430 _encodeObject
4 Foundation 0x30dab84b8 -[NSKeyedArchiver _encodeArrayOfObjects:forKey:]
5 Foundation 0x30dab88d0 -[NSDictionary(NSDictionary) encodeWithCoder:]
6 Foundation 0x30dab7614 _encodeObject
7 LaunchServices 0x30c704fd4 -[_LSRemoteOpenCallApplicationParameters encodeWithCoder:]
8 Foundation 0x30dab7614 _encodeObject
9 LaunchServices 0x30c705420 -[_LSRemoteOpenCallInputs encodeWithCoder:]
10 Foundation 0x30dab7614 _encodeObject
11 LaunchServices 0x30c7042c0 -[_LSRemoteOpenCall encodeWithCoder:]
12 Foundation 0x30dab7614 _encodeObject
13 Foundation 0x30dab6b84 +[NSKeyedArchiver archivedDataWithRootObject:requiringSecureCoding:error:]
14 LaunchServices 0x30c703aa0 -[_LSRemoteOpenCall invokeWithError:]
15 LaunchServices 0x30c617880 _LSOpenStuff
16 LaunchServices 0x30c715d80 _LSOpenAsyncCommonDispatched
17 libdispatch.dylib 0x30b8469dc _dispatch_call_block_and_release
18 libdispatch.dylib 0x30b848504 _dispatch_client_callout
19 libdispatch.dylib 0x30b84fbbc _dispatch_lane_serial_drain
20 libdispatch.dylib 0x30b85073c _dispatch_lane_invoke
21 libdispatch.dylib 0x30b85b34c _dispatch_workloop_worker_thread
22 libsystem_pthread.dylib 0x30bb4f100 _pthread_wqthread
Thread 13
0 libsystem_kernel.dylib 0x30badca1c __workq_kernreturn
1 libsystem_pthread.dylib 0x30bb4f14c _pthread_wqthread
Thread 14
0 libsystem_kernel.dylib 0x30badca1c __workq_kernreturn
1 libsystem_pthread.dylib 0x30bb4f14c _pthread_wqthread
It looks like the crash happens here https://github.com/getsentry/sentry-cocoa/blob/3b2f6027812abea089dea822726c1be86d3d612b/Sources/Sentry/SentryBreadcrumb.m#L33
@sindresorhus, do you manually add breadcrumbs that set something to SentryBreadcrumb.data?
Here's my function:
func addBreadcrumb(
_ message: String,
data: [String: Any]? = nil
) {
let breadcrumb = Breadcrumb(level: .info, category: "app.ss")
breadcrumb.message = message
if let data {
breadcrumb.data = data
}
SentrySDK.addBreadcrumb(crumb: breadcrumb)
}
Thanks for the update, @sindresorhus. What do you put into data?
We need to check why we get Attempted to dereference garbage pointer 0xdeadbeef. when serializing the data.
SSApp.addBreadcrumb(
"Opening URLs",
data: [
"app": bundleIdentifier, // BundleIdentifier
"schemes": urls.map(\.scheme), // [String]
"lastOpenedDate": lastOpenedDate // Date
]
)
struct BundleIdentifier: RawRepresentable, Hashable {
let rawValue: String
}
extension BundleIdentifier: ExpressibleByStringLiteral {
init(stringLiteral value: String) {
self.init(rawValue: value)
}
}
extension BundleIdentifier: Codable {
public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
self.rawValue = try container.decode(String.self)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(rawValue)
}
}
Thanks for the update, @sindresorhus. I (and also @armcknight 😀) wonder why we are using strong instead of copy for this property on SentryBreadcrumb: @property (nonatomic, strong) NSDictionary<NSString *, id> *_Nullable data;
Anyways, we should better safeguard how we treat data in the data property. @armcknight, please add your ideas below as a comment.
👋 Hi there! Our app has also started experiencing a crash when calling addBreadcrumb as soon as we started using it. The stacktrace looks slightly different but I could be related. I was asked to append to this issue instead of creating a new one, but happy to do so if required.
Platform
iOS
Environment
Production, TestFlight
Installed
Swift Package Manager
Version
8.33.0
Xcode Version
15.1
Steps to Reproduce
Cannot reproduce. Multiple crashes from users since we started adding breadcrumbs.
Expected Result
I expected the Sentry SDK to never crash my app.
Actual Result
Crash log:
Incident Identifier: 5098945D-4FD6-4A2E-B2A7-508C005EEE57
Distributor ID: com.apple.TestFlight
Hardware Model: iPhone16,1
Process: Redacted [98382]
Path: /private/var/containers/Bundle/Application/A5C12785-EC27-3DFA-A285-0C61CE41E0C6/Redacted.app/Redacted
Identifier: com.redacted
Version: 5.89.0 (5890053)
AppStoreTools: 15F31e
AppVariant: 1:iPhone16,1:17.4
Beta: YES
Code Type: ARM-64 (Native)
Role: unknown
Parent Process: launchd [1]
Coalition: com.redacted [7710]
Date/Time: 2024-08-29 00:40:27.5233 +0100
Launch Time: 2024-08-28 23:41:38.6205 +0100
OS Version: iPhone OS 17.5.1 (21F90)
Release Type: User
Baseband Version: 1.60.02
Report Version: 104
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: RUNNINGBOARD 0xdead10cc
Triggered by Thread: 0
Thread 0 name:
Thread 0 Crashed:
0 Redacted 0x00000001084c9a40 sentrycrashjson_beginEncode + 0
1 Redacted 0x00000001084b3564 +[SentryCrashJSONCodec encode:options:error:] + 116
2 Redacted 0x0000000108446568 -[SentryCrashScopeObserver toJSONEncodedCString:] + 76
3 Redacted 0x0000000108446354 -[SentryCrashScopeObserver addSerializedBreadcrumb:] + 16
4 Redacted 0x00000001084af614 -[SentryScope addBreadcrumb:] + 480
5 Redacted 0x000000010847cfd4 -[SentryHub addBreadcrumb:] + 200
6 Redacted 0x00000001084ae0e0 +[SentrySDK addBreadcrumb:] + 60
7 Redacted 0x00000001005c7c98 CrashReporter.sentryAddBreadcrumb(_:level:) + 28 (CrashReporter.swift:83)
8 Redacted 0x00000001005c7c98 specialized CrashReporter.logAndBreadcrumb(message:) + 188 (CrashReporter.swift:49)
9 Redacted 0x00000001053062f4 MultipleObjectsRepository.cache(models:completion:file:line:) + 396
10 Redacted 0x0000000106a12d54 OverviewFrameworkRepository.modifyAndCache(model:updatePrimaryKey:completion:) + 348
11 Redacted 0x0000000103be35d4 closure #1 in AggregatedAccountRepository.fetchAndCacheOverview(reason:trigger:completion:) + 1192 (AggregatedAccountRepository.swift:234)
12 Redacted 0x0000000103d07928 closure #1 in AggregatedAccountService.fetch(userContextID:reason:trigger:syncId:completion:) + 932 (AggregatedAccountService.swift:108)
13 Redacted 0x000000010526a7ec closure #1 in closure #2 in closure #1 in OAuthClient.request<A, B>(_:key:unmarshallingQueue:measurementToProfile:serviceFile:serviceLine:completion:) + 136
14 Redacted 0x000000010141c124 thunk for @escaping @callee_guaranteed () -> () + 28 (<compiler-generated>:0)
15 libdispatch.dylib 0x0000000191bf813c _dispatch_call_block_and_release + 32 (init.c:1530)
16 libdispatch.dylib 0x0000000191bf9dd4 _dispatch_client_callout + 20 (object.m:576)
17 libdispatch.dylib 0x0000000191c085a4 _dispatch_main_queue_drain + 988 (queue.c:7898)
18 libdispatch.dylib 0x0000000191c081b8 _dispatch_main_queue_callback_4CF + 44 (queue.c:8058)
19 CoreFoundation 0x0000000189d27710 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 (CFRunLoop.c:1780)
20 CoreFoundation 0x0000000189d24914 __CFRunLoopRun + 1996 (CFRunLoop.c:3149)
21 CoreFoundation 0x0000000189d23cd8 CFRunLoopRunSpecific + 608 (CFRunLoop.c:3420)
22 GraphicsServices 0x00000001cebd41a8 GSEventRunModal + 164 (GSEvent.c:2196)
23 UIKitCore 0x000000018c35c90c -[UIApplication _run] + 888 (UIApplication.m:3713)
24 UIKitCore 0x000000018c4109d0 UIApplicationMain + 340 (UIApplication.m:5303)
25 Redacted 0x00000001003e8ddc main + 268 (main.swift:20)
26 dyld 0x00000001ad3d5e4c start + 2240 (dyldMain.cpp:1298)
Thread 1 name:
Thread 1:
0 libsystem_kernel.dylib 0x00000001d2e0a1cc __psynch_cvwait + 8 (:-1)
1 libsystem_pthread.dylib 0x00000001e6baa6e4 _pthread_cond_wait + 1228 (pthread_cond.c:862)
2 libc++.1.dylib 0x000000019a10a598 std::__1::condition_variable::__do_timed_wait(std::__1::unique_lock<std::__1::mutex>&, std::__1::chrono::time_point<std::__1::chrono::system_clock, std::__1::chrono::duration<long long, std::__1::r... + 100 (condition_variable.cpp:75)
3 StripeTerminal 0x000000010ce020ac void kotlin::RepeatedTimer<kotlin::steady_clock>::Run<kotlin::gcScheduler::internal::GCSchedulerDataAdaptive<kotlin::steady_clock>::GCSchedulerDataAdaptive(kotlin::gcScheduler::GCSchedulerConfig&, ... + 260 (:-1)
4 StripeTerminal 0x000000010ce02334 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, void (*)(kotlin::ScopedThread::attributes, void ... + 112 (:-1)
5 libsystem_pthread.dylib 0x00000001e6bad06c _pthread_start + 136 (pthread.c:931)
6 libsystem_pthread.dylib 0x00000001e6ba80d8 thread_start + 8 (:-1)
Thread 2 name:
Thread 2:
0 libsystem_kernel.dylib 0x00000001d2e0a1cc __psynch_cvwait + 8 (:-1)
1 libsystem_pthread.dylib 0x00000001e6baa6e4 _pthread_cond_wait + 1228 (pthread_cond.c:862)
2 libc++.1.dylib 0x000000019a10a504 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28 (condition_variable.cpp:45)
3 StripeTerminal 0x000000010ce0642c std::__1::invoke_result<kotlin::gc::ConcurrentMarkAndSweep::ConcurrentMarkAndSweep(kotlin::mm::ObjectFactory<kotlin::gc::ConcurrentMarkAndSweep>&, kotlin::mm::ExtraObjectDataFactory&, kotlin::gcSch... + 368 (:-1)
4 StripeTerminal 0x000000010ce080c8 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, void (*)(kotlin::ScopedThread::attributes, kotli... + 104 (:-1)
5 libsystem_pthread.dylib 0x00000001e6bad06c _pthread_start + 136 (pthread.c:931)
6 libsystem_pthread.dylib 0x00000001e6ba80d8 thread_start + 8 (:-1)
Thread 3:
0 libsystem_kernel.dylib 0x00000001d2e09ab8 read + 8 (:-1)
1 Redacted 0x000000010862c92c runtime.read_trampoline.abi0 + 28
Thread 4:
0 libsystem_kernel.dylib 0x00000001d2e0a1cc __psynch_cvwait + 8 (:-1)
1 libsystem_pthread.dylib 0x00000001e6baa710 _pthread_cond_wait + 1272 (pthread_cond.c:862)
2 Redacted 0x000000010862d05c runtime.pthread_cond_timedwait_relative_np_trampoline.abi0 + 28
3 Redacted 0x000000010862b988 runtime.asmcgocall.abi0 + 200
Thread 5:
0 libsystem_kernel.dylib 0x00000001d2e0a1cc __psynch_cvwait + 8 (:-1)
1 libsystem_pthread.dylib 0x00000001e6baa6e4 _pthread_cond_wait + 1228 (pthread_cond.c:862)
2 Redacted 0x000000010862d028 runtime.pthread_cond_wait_trampoline.abi0 + 24
3 Redacted 0x000000010862b988 runtime.asmcgocall.abi0 + 200
Thread 6:
0 libsystem_kernel.dylib 0x00000001d2e0a1cc __psynch_cvwait + 8 (:-1)
1 libsystem_pthread.dylib 0x00000001e6baa6e4 _pthread_cond_wait + 1228 (pthread_cond.c:862)
2 Redacted 0x000000010862d028 runtime.pthread_cond_wait_trampoline.abi0 + 24
3 Redacted 0x000000010862b988 runtime.asmcgocall.abi0 + 200
Thread 7:
0 libsystem_kernel.dylib 0x00000001d2e0a1cc __psynch_cvwait + 8 (:-1)
1 libsystem_pthread.dylib 0x00000001e6baa6e4 _pthread_cond_wait + 1228 (pthread_cond.c:862)
2 Redacted 0x000000010862d028 runtime.pthread_cond_wait_trampoline.abi0 + 24
3 Redacted 0x000000010862b989 runtime.asmcgocall.abi0 + 201
Thread 8:
0 libsystem_kernel.dylib 0x00000001d2e0a1cc __psynch_cvwait + 8 (:-1)
1 libsystem_pthread.dylib 0x00000001e6baa6e4 _pthread_cond_wait + 1228 (pthread_cond.c:862)
2 Redacted 0x000000010862d028 runtime.pthread_cond_wait_trampoline.abi0 + 24
3 Redacted 0x000000010862b988 runtime.asmcgocall.abi0 + 200
Thread 9 name:
Thread 9:
0 libsystem_kernel.dylib 0x00000001d2e04808 mach_msg2_trap + 8 (:-1)
1 libsystem_kernel.dylib 0x00000001d2e08008 mach_msg2_internal + 80 (mach_msg.c:201)
2 libsystem_kernel.dylib 0x00000001d2e07f20 mach_msg_overwrite + 436 (mach_msg.c:0)
3 libsystem_kernel.dylib 0x00000001d2e07d60 mach_msg + 24 (mach_msg.c:323)
4 CoreFoundation 0x0000000189d24f5c __CFRunLoopServiceMachPort + 160 (CFRunLoop.c:2624)
5 CoreFoundation 0x0000000189d24600 __CFRunLoopRun + 1208 (CFRunLoop.c:3007)
6 CoreFoundation 0x0000000189d23cd8 CFRunLoopRunSpecific + 608 (CFRunLoop.c:3420)
7 Foundation 0x0000000188c44e4c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212 (NSRunLoop.m:373)
8 Foundation 0x0000000188c44c9c -[NSRunLoop(NSRunLoop) runUntilDate:] + 64 (NSRunLoop.m:420)
9 UIKitCore 0x000000018c370640 -[UIEventFetcher threadMain] + 420 (UIEventFetcher.m:1207)
10 Foundation 0x0000000188c5b718 __NSThread__start__ + 732 (NSThread.m:991)
11 libsystem_pthread.dylib 0x00000001e6bad06c _pthread_start + 136 (pthread.c:931)
12 libsystem_pthread.dylib 0x00000001e6ba80d8 thread_start + 8 (:-1)
Thread 10:
0 libsystem_kernel.dylib 0x00000001d2e0a1cc __psynch_cvwait + 8 (:-1)
1 libsystem_pthread.dylib 0x00000001e6baa6e4 _pthread_cond_wait + 1228 (pthread_cond.c:862)
2 Redacted 0x000000010862d028 runtime.pthread_cond_wait_trampoline.abi0 + 24
3 Redacted 0x000000010862b988 runtime.asmcgocall.abi0 + 200
Thread 11 name:
Thread 11:
0 libsystem_kernel.dylib 0x00000001d2e0b608 kevent + 8 (:-1)
1 Redacted 0x00000001075d4a68 realm::_impl::ExternalCommitHelper::listen() + 160
2 Redacted 0x00000001075d4b64 void* std::__1::__thread_proxy[abi:v160006]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, realm::_impl::ExternalCommitHelper:... + 56
3 libsystem_pthread.dylib 0x00000001e6bad06c _pthread_start + 136 (pthread.c:931)
4 libsystem_pthread.dylib 0x00000001e6ba80d8 thread_start + 8 (:-1)
Thread 12:
0 libsystem_kernel.dylib 0x00000001d2e0a3ec __semwait_signal + 8 (:-1)
1 libsystem_c.dylib 0x0000000191c535f0 nanosleep + 220 (nanosleep.c:104)
2 libsystem_c.dylib 0x0000000191cb072c sleep + 52 (sleep.c:62)
3 Redacted 0x000000010849c268 monitorCachedData + 660
4 libsystem_pthread.dylib 0x00000001e6bad06c _pthread_start + 136 (pthread.c:931)
5 libsystem_pthread.dylib 0x00000001e6ba80d8 thread_start + 8 (:-1)
Thread 13 name:
Thread 13:
0 libsystem_kernel.dylib 0x00000001d2e04808 mach_msg2_trap + 8 (:-1)
1 libsystem_kernel.dylib 0x00000001d2e08008 mach_msg2_internal + 80 (mach_msg.c:201)
2 libsystem_kernel.dylib 0x00000001d2e05d78 thread_suspend + 112 (thread_actUser.c:1036)
3 Redacted 0x0000000108482778 handleExceptions + 128
4 libsystem_pthread.dylib 0x00000001e6bad06c _pthread_start + 136 (pthread.c:931)
5 libsystem_pthread.dylib 0x00000001e6ba80d8 thread_start + 8 (:-1)
Thread 14 name:
Thread 14:
0 libsystem_kernel.dylib 0x00000001d2e04808 mach_msg2_trap + 8 (:-1)
1 libsystem_kernel.dylib 0x00000001d2e08008 mach_msg2_internal + 80 (mach_msg.c:201)
2 libsystem_kernel.dylib 0x00000001d2e07f20 mach_msg_overwrite + 436 (mach_msg.c:0)
3 libsystem_kernel.dylib 0x00000001d2e07d60 mach_msg + 24 (mach_msg.c:323)
4 Redacted 0x00000001084827a4 handleExceptions + 172
5 libsystem_pthread.dylib 0x00000001e6bad06c _pthread_start + 136 (pthread.c:931)
6 libsystem_pthread.dylib 0x00000001e6ba80d8 thread_start + 8 (:-1)
Thread 15 name:
Thread 15:
0 libsystem_kernel.dylib 0x00000001d2e0a3ec __semwait_signal + 8 (:-1)
1 libsystem_c.dylib 0x0000000191c535f0 nanosleep + 220 (nanosleep.c:104)
2 Foundation 0x0000000188d97714 +[NSThread sleepForTimeInterval:] + 160 (NSThread.m:527)
3 Redacted 0x0000000108462cc0 -[SentryANRTracker detectANRs] + 556
4 Foundation 0x0000000188c5b718 __NSThread__start__ + 732 (NSThread.m:991)
5 libsystem_pthread.dylib 0x00000001e6bad06c _pthread_start + 136 (pthread.c:931)
6 libsystem_pthread.dylib 0x00000001e6ba80d8 thread_start + 8 (:-1)
Thread 16 name:
Thread 16:
0 libsystem_kernel.dylib 0x00000001d2e04808 mach_msg2_trap + 8 (:-1)
1 libsystem_kernel.dylib 0x00000001d2e08008 mach_msg2_internal + 80 (mach_msg.c:201)
2 libsystem_kernel.dylib 0x00000001d2e07f20 mach_msg_overwrite + 436 (mach_msg.c:0)
3 libsystem_kernel.dylib 0x00000001d2e07d60 mach_msg + 24 (mach_msg.c:323)
4 CoreFoundation 0x0000000189d24f5c __CFRunLoopServiceMachPort + 160 (CFRunLoop.c:2624)
5 CoreFoundation 0x0000000189d24600 __CFRunLoopRun + 1208 (CFRunLoop.c:3007)
6 CoreFoundation 0x0000000189d23cd8 CFRunLoopRunSpecific + 608 (CFRunLoop.c:3420)
7 CFNetwork 0x000000018af04c90 +[__CFN_CoreSchedulingSetRunnable _run:] + 384 (CoreSchedulingSet.mm:1473)
8 Foundation 0x0000000188c5b718 __NSThread__start__ + 732 (NSThread.m:991)
9 libsystem_pthread.dylib 0x00000001e6bad06c _pthread_start + 136 (pthread.c:931)
10 libsystem_pthread.dylib 0x00000001e6ba80d8 thread_start + 8 (:-1)
Thread 17 name:
Thread 17:
0 libsystem_kernel.dylib 0x00000001d2e0479c semaphore_timedwait_trap + 8 (:-1)
1 libdispatch.dylib 0x0000000191bfa3ec _dispatch_sema4_timedwait + 64 (lock.c:154)
2 libdispatch.dylib 0x0000000191bfa9e8 _dispatch_semaphore_wait_slow + 76 (semaphore.c:116)
3 libswiftDispatch.dylib 0x00000001930f457c OS_dispatch_semaphore.wait(wallTimeout:) + 24 (Dispatch.swift:189)
4 Redacted 0x0000000105223374 ExperimentalOverviewModelParsingBackgroundThreadSupportingBackgroundTask.main() + 736
5 Redacted 0x0000000105223674 @objc ExperimentalOverviewModelParsingBackgroundThreadSupportingBackgroundTask.main() + 28
6 Foundation 0x0000000188c5b718 __NSThread__start__ + 732 (NSThread.m:991)
7 libsystem_pthread.dylib 0x00000001e6bad06c _pthread_start + 136 (pthread.c:931)
8 libsystem_pthread.dylib 0x00000001e6ba80d8 thread_start + 8 (:-1)
Thread 18:
0 libsystem_pthread.dylib 0x00000001e6ba80c4 start_wqthread + 0 (:-1)
Thread 19:
0 libsystem_pthread.dylib 0x00000001e6ba80c4 start_wqthread + 0 (:-1)
Thread 20:
0 libsystem_pthread.dylib 0x00000001e6ba80c4 start_wqthread + 0 (:-1)
Thread 21:
0 libsystem_pthread.dylib 0x00000001e6ba80c4 start_wqthread + 0 (:-1)
Thread 22:
0 libsystem_pthread.dylib 0x00000001e6ba80c4 start_wqthread + 0 (:-1)
Thread 23:
0 libsystem_pthread.dylib 0x00000001e6ba80c4 start_wqthread + 0 (:-1)
Thread 24:
0 libsystem_pthread.dylib 0x00000001e6ba80c4 start_wqthread + 0 (:-1)
Thread 25:
0 libsystem_kernel.dylib 0x00000001d2e0a1cc __psynch_cvwait + 8 (:-1)
1 libsystem_pthread.dylib 0x00000001e6baa6e4 _pthread_cond_wait + 1228 (pthread_cond.c:862)
2 libc++.1.dylib 0x000000019a10a504 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28 (condition_variable.cpp:45)
3 Redacted 0x0000000107563ae0 realm::DB::AsyncCommitHelper::main() + 268
4 Redacted 0x0000000107567868 void* std::__1::__thread_proxy[abi:v160006]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, realm::DB::AsyncCommitHelper::start... + 52
5 libsystem_pthread.dylib 0x00000001e6bad06c _pthread_start + 136 (pthread.c:931)
6 libsystem_pthread.dylib 0x00000001e6ba80d8 thread_start + 8 (:-1)
Thread 26:
0 libsystem_pthread.dylib 0x00000001e6ba80c4 start_wqthread + 0 (:-1)
Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x000000016fa19b48 x1: 0x0000000000000000 x2: 0x00000001084b3610 x3: 0x00000003020bc960
x4: 0x0000000000000003 x5: 0x0000000000000c30 x6: 0x0000000302f30c30 x7: 0x000000016fa192f0
x8: 0x00000001eaa4c100 x9: 0x0000000000000008 x10: 0x01000001eaa5f431 x11: 0x00000000a0080001
x12: 0x0000000302f9ccbc x13: 0x00000000001ff800 x14: 0x00000000000007fb x15: 0x00000000e935f0c4
x16: 0x0000000181bcf14c x17: 0x00000000e955e854 x18: 0x0000000000000000 x19: 0x000000016fa19c88
x20: 0x00000003020bc960 x21: 0x0000000000000002 x22: 0x000000010a65b9f8 x23: 0x0000000302cc9100
x24: 0x0000000302fbe120 x25: 0x0000000200000003 x26: 0x0000000000000000 x27: 0x000000000000004f
x28: 0x000000010a7e1dc0 fp: 0x000000016fa19c60 lr: 0x00000001084b3564
sp: 0x000000016fa19b40 pc: 0x00000001084c9a40 cpsr: 0x60001000
esr: 0x82000007 (Instruction Abort) Translation fault
EOF
Hello @monchote, appending to this one is perfect.
Can you share with us if you're adding any extra information in the breadcrumb?
Can you share with us if you're adding any extra information in the breadcrumb?
Thanks @brustolin. This is the function that calls addBreadcrumb in our codebase:
func sentryAddBreadcrumb(_ message: String, level: SentryLevel) {
let crumb = Breadcrumb()
crumb.level = level
crumb.category = "log"
crumb.message = message
SentrySDK.addBreadcrumb(crumb)
}
Thank you @monchote. We will investigate what is the problem.
@brustolin Do you have an estimation on when we could expect a fix?
We’ve had over 1200 instances of this crash in the last 2 weeks and almost 8000 since we started using breadcrumbs so we may be forced to disable them thus severely reducing the capabilities of Sentry to help us track, reproduce, and fix crashes.
Do you have an estimation on when we could expect a fix?
Unfortunately no. I was unable to reproduce this error yet. We dont know what is wrong it with to be able to fix.
We also see this in our internal SDK crash detection.
Hi folks, any update on this?
We suspect this is happening when calling addBreadcrumb from multiple threads. We're going to try to serialise these calls using a single queue.
Could you confirm it's safe to call this from a non-main thread as mentioned here? I couldn't find anything on this in the docs.
@monchote, no, sadly, we don't have any update on this. We see only a few occurrences of this problem.
addBreadcrumb is thread safe. You can call it from any thread: https://github.com/getsentry/sentry-cocoa/blob/522f8da1aef040a58ae580345895e2ec1c215d36/Sources/Sentry/SentryScope.m#L119-L140
We suspect this is happening when calling addBreadcrumb from multiple threads. We're going to try to serialise these calls using a single queue.
That's weird. Do you maybe modify the breadcrumbs after adding calling addBreadcrumb?
Hey all - I'm also seeing occasional crashes here, however it looks like Sentry never even makes it to the deserialization calls and its a slightly different crash. I can see Sentry calls only happening on one thread where it then crashes:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Codes: 0x0000000000000001, 0x0000000000000000
VM Region Info: 0 is not in any region. Bytes before following region: 4299325440
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
__TEXT 100428000-100bc8000 [ 7808K] r-x/r-x SM=COW /var/containers/Bundle/Application/248C89EE-E3CB-4BC2-88F4-57A8B239D3D2/Trustpilot.app/Trustpilot
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [12362]
Triggered by Thread: 4
.....
Thread 4 Crashed:
0 libsystem_platform.dylib 0x000000022078df54 _platform_strstr + 52 (strstr.c:54)
1 Trustpilot 0x0000000100fb36fc sentrycrashdl_imageNamed + 76
2 Trustpilot 0x0000000100fb2754 setEnabled + 404
3 Trustpilot 0x0000000100f6259c -[SentryCrashWrapper init] + 68
4 Trustpilot 0x0000000100f62540 __36+[SentryCrashWrapper sharedInstance]_block_invoke + 20
5 libdispatch.dylib 0x000000019e334584 _dispatch_client_callout + 16 (client_callout.mm:85)
6 libdispatch.dylib 0x000000019e31d9a8 _dispatch_once_callout + 32 (once.c:52)
7 Trustpilot 0x0000000100f62528 +[SentryCrashWrapper sharedInstance] + 112
8 Trustpilot 0x0000000100fb9744 -[SentryDependencyContainer init] + 396
9 Trustpilot 0x0000000100fb9480 +[SentryDependencyContainer initialize] + 128
10 libobjc.A.dylib 0x0000000193905f80 CALLING_SOME_+initialize_METHOD + 24 (objc-initialize.mm:571)
11 libobjc.A.dylib 0x000000019390582c initializeNonMetaClass + 728 (objc-initialize.mm:762)
12 libobjc.A.dylib 0x0000000193905b9c initializeAndMaybeRelock(objc_class*, objc_object*, locker_mixin<lockdebug::lock_mixin<objc_lock_base_t>>&, bool) + 176 (objc-runtime-new.mm:2600)
13 libobjc.A.dylib 0x000000019390152c lookUpImpOrForward + 292 (objc-runtime-new.mm:7718)
14 libobjc.A.dylib 0x00000001939020e4 _objc_msgSend_uncached + 68 (:-1)
15 Trustpilot 0x0000000100f7d2ec -[SentryHub initWithClient:andScope:] + 72
16 Trustpilot 0x0000000100fa8860 +[SentrySDK currentHub] + 68
17 Trustpilot 0x0000000100fa9ffc +[SentrySDK addBreadcrumb:] + 40
18 Trustpilot 0x0000000100a61f8c specialized SentryUtility.addBreadcrumb(_:) + 448 (SentryUtility.swift:79)
19 Trustpilot 0x000000010044677c specialized RepositoryWorker.recordBreadcrumb(stage:) + 148 (RepositoryWorker.swift:97)
20 Trustpilot 0x000000010044677c specialized RepositoryWorker.fetchLatestData() + 1264 (RepositoryWorker.swift:233)
21 Trustpilot 0x00000001004407d8 specialized closure #1 in RepositoryWorker.stateStream(fetch:) + 28 (RepositoryWorker.swift:35)
22 Trustpilot 0x000000010045a3dd partial apply for specialized thunk for @escaping @isolated(any) @callee_guaranteed @async () -> (@out A) + 1
23 Trustpilot 0x000000010045a3e5 specialized thunk for @escaping @isolated(any) @callee_guaranteed @async () -> (@out A) + 1
24 Trustpilot 0x000000010045a3dd partial apply for specialized thunk for @escaping @isolated(any) @callee_guaranteed @async () -> (@out A) + 1
25 libswift_Concurrency.dylib 0x00000001a1de1241 completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) + 1 (Task.cpp:537)
Similar to others, I can't actually reproduce and only seeing through crash logs.
Was this issue ever reproduced or cause determined?
@P-Foley-Trustpilot, thanks for the report. This looks like a slightly different crash. It seems like you call addBreadcrumb very early during your app launch, maybe even before you call SentrySDK.start. If that's the case, then we might miss covering this edge case, and I think we should create an extra issue for this.
@P-Foley-Trustpilot, thanks for the report. This looks like a slightly different crash. It seems like you call
addBreadcrumbvery early during your app launch, maybe even before you callSentrySDK.start. If that's the case, then we might miss covering this edge case, and I think we should create an extra issue for this.
@philipphofmann No addBreadcrumb() calls are made before SentrySDK.start. If I try calling addBreadcrumb() before any SentrySDK.start I get a valid error message, rather than a crash so it seems unlikely thats the cause of this crash.
Should I raise a separate issue for this? I've also updated to the latest package version of Sentry in hopes there could be a fix there somewhere (we were around 4 minor versions behind)
Yes, please create an exra issue for that @P-Foley-Trustpilot.