I had an app in the App Store with lots of crashes, but I can't reproduce it myself. I have lots of crash logs but they don't contain a backtrace making it difficult to diagnose the issue.
The crash logs show CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER which possibly could be caused by a notification being sent to a deallocated observer according to other questions on SO. However the app only runs on iOS 10+, and according to Apple its not necessary to de-register observers from iOS 9 onwards unless they are block observers. Which my app doesn't use so that can't be the cause as far as my own apps notifications are concerned.
Incident Identifier: 77AB1312-9C1F-4BC1-957E-B742856DC635
CrashReporter Key: 6ad59ac64c53d2fc92208e8df23d4ddc8fed39fd
Hardware Model: iPhone10,3
Process: My App [378]
Path: /private/var/containers/Bundle/Application/99C2E2C8-9655-4D07-9608-870B5DD17C21/My app.app/My app
Identifier: com.myapp
OS Version: iPhone OS 10.3.2 (14F89)
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: com.myapp[498]
Date/Time: 2018-06-06 00:18:34.2085 -0700
Launch Time: 2018-06-06 00:17:39.1406 -0700
Baseband Version: 2.03.00
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Thread 0 name:
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x000000018ec4d014 __pthread_kill + 8
1 libsystem_pthread.dylib 0x000000018ed17264 pthread_kill + 112 (pthread.c:1366)
2 libsystem_c.dylib 0x000000018ebc19c4 abort + 140 (abort.c:91)
3 libswiftCore.dylib 0x0000000100ad976c 0x1007ec000 + 3069804
4 libswiftCore.dylib 0x0000000100b0614c 0x1007ec000 + 3252556
5 CoreFoundation 0x000000018fc56f54 ___forwarding___ + 916 (NSForwarding.m:3126)
6 CoreFoundation 0x000000018fb52d4c _CF_forwarding_prep_0 + 92
7 CoreFoundation 0x000000018fbed5f4 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20 (CFNotificationCenter.c:650)
8 CoreFoundation 0x000000018fbecd08 _CFXRegistrationPost + 400 (CFNotificationCenter.c:164)
9 CoreFoundation 0x000000018fbeca84 ___CFXNotificationPost_block_invoke + 60 (CFNotificationCenter.c:1031)
10 CoreFoundation 0x000000018fc5b7a8 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1412 (CFXNotificationRegistrar.m:163)
11 CoreFoundation 0x000000018fb3095c _CFXNotificationPost + 376 (CFNotificationCenter.c:1028)
12 Foundation 0x0000000190642930 -[NSNotificationCenter postNotificationName:object:userInfo:] + 68 (NSNotification.m:482)
13 UIKit 0x0000000195e07ea8 -[UIApplication _stopDeactivatingForReason:] + 1124 (UIApplication.m:1534)
14 UIKit 0x0000000196005b4c __62-[UIApplication _sceneSettingsPostLifecycleEventDiffInspector]_block_invoke.1259 + 124 (UIApplication.m:3247)
15 FrontBoardServices 0x00000001917e4be8 __52-[FBSSettingsDiffInspector inspectDiff:withContext:]_block_invoke.27 + 204 (FBSSettingsDiffInspector.m:46)
16 Foundation 0x00000001906fc7fc __NSIndexSetEnumerate + 724 (NSIndexSet.m:1347)
17 BaseBoard 0x0000000191757510 -[BSSettingsDiff inspectChangesWithBlock:] + 104 (BSSettingsDiff.m:187)
18 FrontBoardServices 0x00000001917dece4 -[FBSSettingsDiff inspectOtherChangesWithBlock:] + 88 (FBSSettingsDiff.m:65)
19 FrontBoardServices 0x00000001917e49bc -[FBSSettingsDiffInspector inspectDiff:withContext:] + 280 (FBSSettingsDiffInspector.m:44)
20 UIKit 0x00000001960064d4 __70-[UIApplication scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 196 (UIApplication.m:3346)
21 UIKit 0x0000000196006124 -[UIApplication scene:didUpdateWithDiff:transitionContext:completion:] + 892 (UIApplication.m:3357)
22 UIKit 0x00000001963407c8 -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 464 (UIApplicationSceneClientAgent.m:74)
23 FrontBoardServices 0x00000001917ce22c __80-[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:]_block_invoke.376 + 208 (FBSSceneImpl.m:598)
24 FrontBoardServices 0x00000001917fb884 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36 (FBSSerialQueue.m:158)
25 FrontBoardServices 0x00000001917fb6f0 -[FBSSerialQueue _performNext] + 176 (FBSSerialQueue.m:177)
26 FrontBoardServices 0x00000001917fbaa0 -[FBSSerialQueue _performNextFromRunLoopSource] + 56 (FBSSerialQueue.m:206)
27 CoreFoundation 0x000000018fc0142c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 (CFRunLoop.c:1943)
28 CoreFoundation 0x000000018fc00d9c __CFRunLoopDoSources0 + 540 (CFRunLoop.c:1989)
29 CoreFoundation 0x000000018fbfe9a8 __CFRunLoopRun + 744 (CFRunLoop.c:2821)
30 CoreFoundation 0x000000018fb2eda4 CFRunLoopRunSpecific + 424 (CFRunLoop.c:3113)
31 GraphicsServices 0x0000000191598074 GSEventRunModal + 100 (GSEvent.c:2245)
32 UIKit 0x0000000195de9058 UIApplicationMain + 208 (UIApplication.m:4089)
33 My App 0x00000001000be2e4 main + 56 (MyFile.swift:17)
34 libdyld.dylib 0x000000018eb3d59c start + 4
hread 1:
0 libsystem_pthread.dylib 0x0000000220f92064 start_wqthread + 0
Thread 2 name:
Thread 2:
0 libsystem_kernel.dylib 0x0000000220ef6ac8 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x0000000220ef6940 mach_msg + 72 (mach_msg.c:103)
2 CoreFoundation 0x000000022131d2f0 __CFRunLoopServiceMachPort + 236 (CFRunLoop.c:2615)
3 CoreFoundation 0x000000022131af80 __CFRunLoopRun + 1404 (CFRunLoop.c:2971)
4 CoreFoundation 0x0000000221254abc CFRunLoopRunSpecific + 436 (CFRunLoop.c:3247)
5 Foundation 0x0000000221cd0544 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 300 (NSRunLoop.m:367)
6 Foundation 0x0000000221cd03f0 -[NSRunLoop(NSRunLoop) runUntilDate:] + 148 (NSRunLoop.m:411)
7 UIKitCore 0x000000024c433a7c -[UIEventFetcher threadMain] + 136 (UIEventFetcher.m:524)
8 Foundation 0x0000000221de0a94 __NSThread__start__ + 1040 (NSThread.m:1175)
9 libsystem_pthread.dylib 0x0000000220f931e4 _pthread_body + 128 (pthread.c:804)
10 libsystem_pthread.dylib 0x0000000220f93164 _pthread_start + 40 (pthread.c:827)
11 libsystem_pthread.dylib 0x0000000220f92070 thread_start + 4
Thread 3 name:
Thread 3:
0 libsystem_kernel.dylib 0x0000000220ef6ac8 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x0000000220ef6940 mach_msg + 72 (mach_msg.c:103)
2 CoreFoundation 0x000000022131d2f0 __CFRunLoopServiceMachPort + 236 (CFRunLoop.c:2615)
3 CoreFoundation 0x000000022131af80 __CFRunLoopRun + 1404 (CFRunLoop.c:2971)
4 CoreFoundation 0x0000000221254abc CFRunLoopRunSpecific + 436 (CFRunLoop.c:3247)
5 CFNetwork 0x0000000221b5fc8c -[__CoreSchedulingSetRunnable runForever] + 212 (CoreSchedulingSet.mm:1365)
6 Foundation 0x0000000221de0a94 __NSThread__start__ + 1040 (NSThread.m:1175)
7 libsystem_pthread.dylib 0x0000000220f931e4 _pthread_body + 128 (pthread.c:804)
8 libsystem_pthread.dylib 0x0000000220f93164 _pthread_start + 40 (pthread.c:827)
9 libsystem_pthread.dylib 0x0000000220f92070 thread_start + 4
Thread 4 name:
Thread 4:
0 libsystem_kernel.dylib 0x0000000220f184ac __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x0000000220f9a638 _pthread_cond_wait$VARIANT$armv81 + 620 (pthread_cond.c:578)
2 libc++.1.dylib 0x00000002205b2e28 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 24 (__threading_support:278)
3 JavaScriptCore 0x0000000228f44524 void std::__1::condition_variable_any::wait<std::__1::unique_lock<bmalloc::Mutex> >(std::__1::unique_lock<bmalloc::Mutex>&) + 104 (condition_variable:204)
4 JavaScriptCore 0x0000000228f48300 bmalloc::Scavenger::threadRunLoop() + 172 (condition_variable:213)
5 JavaScriptCore 0x0000000228f47ac4 bmalloc::Scavenger::threadEntryPoint(bmalloc::Scavenger*) + 12 (Scavenger.cpp:352)
6 JavaScriptCore 0x0000000228f494b8 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 (*)(bmalloc::Scavenger*), bmalloc::Scavenger*> >(void*) + 44 (type_traits:4428)
7 libsystem_pthread.dylib 0x0000000220f931e4 _pthread_body + 128 (pthread.c:804)
8 libsystem_pthread.dylib 0x0000000220f93164 _pthread_start + 40 (pthread.c:827)
9 libsystem_pthread.dylib 0x0000000220f92070 thread_start + 4
Thread 5 name:
Thread 5:
0 libsystem_kernel.dylib 0x0000000220efb088 kevent + 8
1 Realm 0x00000001025f112c realm::_impl::ExternalCommitHelper::listen() + 212 (external_commit_helper.cpp:202)
2 Realm 0x00000001025f1d20 std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>::operator()() + 28 (external_commit_helper.cpp:159)
3 Realm 0x00000001025f1ca8 std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::__execute() + 28 (future:1039)
4 Realm 0x00000001025f1e58 std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >*> >(void*, void*) + 64 (type_traits:4232)
5 libsystem_pthread.dylib 0x0000000220f931e4 _pthread_body + 128 (pthread.c:804)
6 libsystem_pthread.dylib 0x0000000220f93164 _pthread_start + 40 (pthread.c:827)
7 libsystem_pthread.dylib 0x0000000220f92070 thread_start + 4
Thread 6 name:
Thread 6:
0 libsystem_kernel.dylib 0x0000000220ef6ac8 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x0000000220ef6940 mach_msg + 72 (mach_msg.c:103)
2 CoreFoundation 0x000000022131d2f0 __CFRunLoopServiceMachPort + 236 (CFRunLoop.c:2615)
3 CoreFoundation 0x000000022131af80 __CFRunLoopRun + 1404 (CFRunLoop.c:2971)
4 CoreFoundation 0x0000000221254abc CFRunLoopRunSpecific + 436 (CFRunLoop.c:3247)
5 AVFAudio 0x0000000227a31cd0 GenericRunLoopThread::Entry(void*) + 164 (GenericRunLoopThread.h:92)
6 AVFAudio 0x0000000227a5ce94 CAPThread::Entry(CAPThread*) + 88
7 libsystem_pthread.dylib 0x0000000220f931e4 _pthread_body + 128 (pthread.c:804)
8 libsystem_pthread.dylib 0x0000000220f93164 _pthread_start + 40 (pthread.c:827)
9 libsystem_pthread.dylib 0x0000000220f92070 thread_start + 4
Thread 7:
0 libsystem_pthread.dylib 0x0000000220f92064 start_wqthread + 0
Thread 8:
0 libsystem_pthread.dylib 0x0000000220f92064 start_wqthread + 0
Thread 9:
0 libsystem_pthread.dylib 0x0000000220f92064 start_wqthread + 0
Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x0000000000000000 x1: 0x0000000000000000 x2: 0x0000000000000000 x3: 0x0000000282a1a766
x4: 0x0000000103938280 x5: 0x0000000000000020 x6: 0x0046000004210103 x7: 0x00000000ffba0038
x8: 0x0000000000000800 x9: 0x0000000220f98b44 x10: 0x0000000220f9408c x11: 0x000000025b529562
x12: 0x000000025b529562 x13: 0x0000000000000018 x14: 0x0000000000000001 x15: 0x0000000000000881
x16: 0x0000000000000148 x17: 0x0000000000000000 x18: 0x0000000000000000 x19: 0x0000000000000006
x20: 0x0000000259099100 x21: 0x000000000000002d x22: 0x0000000000000303 x23: 0x00000002590991e0
x24: 0x0000000000000000 x25: 0x000000024d2a3912 x26: 0x0000000102eec200 x27: 0x000000025909cf10
x28: 0x0000000000000001 fp: 0x000000016ddd9960 lr: 0x0000000220f98c70
sp: 0x000000016ddd9930 pc: 0x0000000220f186a4 cpsr: 0x00000000
FYI Line 17 of MyFile.swift is just this:
@objc class RealmDatabase : NSObject
{
var configuration:Realm.Configuration? = nil // Line 17
Thats just a declaration of an optional, so I don't see how that could cause any problems.
Are there any other clues as to what the problem could be?
Just a wild stab in the dark:
One reason that this error can happen is due to ARC and weak references.
A common pattern in iOS is the delegate pattern, where a separate object is constructed to handle the messages of another object. These references are often weak, so that you don't get a memory cycle, where two objects own a strong reference to each other.
Now, it could be, somewhere in your code, that you are generating a RealmDatabase
instance somewhere, and handing it off to another object as a weak reference. If this is the case, then it will be destroyed by ARC as soon as all the strong references to it are gone: for example, if it is being referenced by a Realm connection instance of some sort, and the connection is dropped.
This is just a wild guess, but if you are dynamically creating RealmDatabase
instances when certain events happen, store references to those objects in a stored property on some object, as an optional, to keep them from being destroyed by ARC.
Good luck, and I hope you solve this for your users.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With