How to fix EXC_CRASH (SIGKILL) watchdog termination? - ios

I am running into a watchdog termination crash. After watching this WWDC session and reading the relevant documentation about watchdog crashes, I suspect there is some kind of deadlock.
But I am unable to understand how my code is causing deadlock. I have removed stack traces of some threads here because of the character limit. The complete crash log can be found in this GitHub gist
Incident Identifier: 5E8D976C-94FC-4400-A729-20BD48E26C7C
Hardware Model: iPhone13,3
Process: Fhetch [73637]
Path: /private/var/containers/Bundle/Application/3581EBF4-AE49-411D-B444-10D2617B1D45/XYZ.app/XYZ
Identifier: com.XYZ.APP
Version: 1.1.3 (18)
AppStoreTools: 13E500
AppVariant: 1:iPhone13,3:15
Beta: YES
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: com.XYZ.APP [2854]
Date/Time: 2022-04-25 14:04:47.1725 -0400
Launch Time: 2022-04-24 23:09:42.3116 -0400
OS Version: iPhone OS 15.4.1 (19E258)
Release Type: User
Baseband Version: 2.53.01
Report Version: 104
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: FRONTBOARD 2343432205
<RBSTerminateContext| domain:10 code:0x8BADF00D explanation:scene-update watchdog transgression: application<com.XYZ.APP>:73637 exhausted real (wall clock) time allowance of 10.00 seconds
ProcessVisibility: Foreground
ProcessState: Running
WatchdogEvent: scene-update
WatchdogVisibility: Background
WatchdogCPUStatistics: (
"Elapsed total CPU time (seconds): 9.260 (user 5.280, system 3.980), 15% CPU",
"Elapsed application CPU time (seconds): 0.101, 0% CPU"
) reportType:CrashLog maxTerminationResistance:Interactive>
Triggered by Thread: 0
Kernel Triage:
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get
Thread 0 name:
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x00000001fcd27bdc kevent_id + 8
1 libdispatch.dylib 0x00000001c4eef1fc _dispatch_kq_poll + 228 (event_kevent.c:750)
2 libdispatch.dylib 0x00000001c4eefc20 _dispatch_event_loop_wait_for_ownership + 444 (event_kevent.c:2209)
3 libdispatch.dylib 0x00000001c4edbf54 __DISPATCH_WAIT_FOR_QUEUE__ + 328 (queue.c:1690)
4 libdispatch.dylib 0x00000001c4edbb28 _dispatch_sync_f_slow + 144 (queue.c:1774)
5 CoreData 0x00000001cc9bfa94 -[NSManagedObjectContext performBlockAndWait:] + 264 (NSManagedObjectContext.m:4059)
6 FHKit 0x00000001016c55c0 closure #1 in static FHDataManager.transfer<A>(_:intoContext:) + 1288 (DataManager+ManagedObjects.swift:56)
7 FHKit 0x000000010166124c thunk for #callee_guaranteed () -> () + 20 (<compiler-generated>:0)
8 FHKit 0x00000001016612ac thunk for #escaping #callee_guaranteed () -> () + 28 (<compiler-generated>:0)
9 CoreData 0x00000001cc9bf834 developerSubmittedBlockToNSManagedObjectContextPerform + 156 (NSManagedObjectContext.m:3942)
10 CoreData 0x00000001cc9bfa5c -[NSManagedObjectContext performBlockAndWait:] + 208 (NSManagedObjectContext.m:4053)
11 FHKit 0x00000001016c4e98 static FHDataManager.transfer<A>(_:intoContext:) + 576 (DataManager+ManagedObjects.swift:49)
12 FHKit 0x00000001016c4404 static FHDataManager.transfer<A>(_:intoContext:) + 951300 (DataManager+ManagedObjects.swift:39)
13 FHKit 0x0000000101776b84 FHIdentifiableEntity.hasSameId<A>(as:) + 596 (IdentifiableEntity.swift:36)
14 FHKit 0x0000000101698a5c FHSubmittableUserAction.supercedes(_:) + 3012 (SubmittableUserAction.swift:77)
15 FHKit 0x000000010186c9bc closure #1 in closure #1 in closure #1 in static FHActionManager.process(submittableUserAction:fromContext:) + 112 (ActionManager+Processing.swift:419)
16 FHKit 0x000000010166124c thunk for #callee_guaranteed () -> () + 20 (<compiler-generated>:0)
17 FHKit 0x00000001016612ac thunk for #escaping #callee_guaranteed () -> () + 28 (<compiler-generated>:0)
18 CoreData 0x00000001cc9bf834 developerSubmittedBlockToNSManagedObjectContextPerform + 156 (NSManagedObjectContext.m:3942)
19 CoreData 0x00000001cc9bfa5c -[NSManagedObjectContext performBlockAndWait:] + 208 (NSManagedObjectContext.m:4053)
20 FHKit 0x000000010186c818 closure #1 in closure #1 in static FHActionManager.process(submittableUserAction:fromContext:) + 668 (ActionManager+Processing.swift:417)
21 FHKit 0x00000001019cc734 closure #1 in closure #1 in static FHNetworkOperationsQueue.remove(operationBlockIf:) + 60 (NetworkOperationsQueue.swift:233)
22 FHKit 0x00000001019cc790 thunk for #callee_guaranteed (#guaranteed FHNetworkOperation) -> (#unowned Bool, #error #owned Error) + 28 (<compiler-generated>:0)
23 FHKit 0x00000001019cd864 partial apply for thunk for #callee_guaranteed (#guaranteed FHNetworkOperation) -> (#unowned Bool, #error #owned Error) + 32 (<compiler-generated>:0)
24 libswiftCore.dylib 0x00000001c9cbec30 _ArrayProtocol.filter(_:) + 1000 (ArrayType.swift:73)
25 FHKit 0x00000001019cc698 closure #1 in static FHNetworkOperationsQueue.remove(operationBlockIf:) + 224 (NetworkOperationsQueue.swift:231)
26 FHKit 0x00000001016ca4b4 thunk for #callee_guaranteed () -> (#error #owned Error) + 24 (<compiler-generated>:0)
27 FHKit 0x00000001019cd828 thunk for #callee_guaranteed () -> (#error #owned Error)partial apply + 32 (<compiler-generated>:0)
28 FHKit 0x00000001016cde5c static FHThreadManager.synchronized<A>(_:shouldLogInfo:_:) + 924 (ThreadAndQueueManagement.swift:195)
29 FHKit 0x00000001016ca460 synchronized<A>(_:shouldLogInfo:_:) + 88 (ThreadAndQueueManagement.swift:211)
30 FHKit 0x00000001019c7624 static FHNetworkOperationsQueue.remove(operationBlockIf:) + 4109860 (NetworkOperationsQueue.swift:229)
31 FHKit 0x000000010186c3f0 closure #1 in static FHActionManager.process(submittableUserAction:fromContext:) + 728 (ActionManager+Processing.swift:409)
32 FHKit 0x00000001016ca4b4 thunk for #callee_guaranteed () -> (#error #owned Error) + 24 (<compiler-generated>:0)
33 FHKit 0x000000010186c510 partial apply for thunk for #callee_guaranteed () -> (#error #owned Error) + 32 (<compiler-generated>:0)
34 FHKit 0x00000001016cde5c static FHThreadManager.synchronized<A>(_:shouldLogInfo:_:) + 924 (ThreadAndQueueManagement.swift:195)
35 FHKit 0x00000001016ca460 synchronized<A>(_:shouldLogInfo:_:) + 88 (ThreadAndQueueManagement.swift:211)
36 FHKit 0x000000010186c0e4 static FHActionManager.process(submittableUserAction:fromContext:) + 476 (ActionManager+Processing.swift:439)
37 FHKit 0x0000000101867638 static FHActionManager.process<A>(actionForRecord:fromContext:) + 680 (ActionManager+Processing.swift:390)
38 FHKit 0x0000000101866e4c static FHActionManager.process(action:forContent:fromContext:bypassingServerInteraction:withTrustedTimestamps:) + 2666060 (ActionManager+Processing.swift:26)
39 Fhetch 0x00000001006e4088 closure #1 in FHChatTableViewController.ensureMessageIsRead(message:) + 2015368 (ChatTableViewController+CoreData.swift:668)
40 Fhetch 0x000000010053e2c4 thunk for #callee_guaranteed () -> () + 20 (<compiler-generated>:0)
41 Fhetch 0x000000010053e324 thunk for #escaping #callee_guaranteed () -> () + 28 (<compiler-generated>:0)
42 CoreData 0x00000001cc9bf834 developerSubmittedBlockToNSManagedObjectContextPerform + 156 (NSManagedObjectContext.m:3942)
43 libdispatch.dylib 0x00000001c4ecca2c _dispatch_client_callout + 20 (object.m:560)
44 libdispatch.dylib 0x00000001c4edbc90 _dispatch_lane_barrier_sync_invoke_and_complete + 56 (queue.c:1028)
45 CoreData 0x00000001cc9bfa94 -[NSManagedObjectContext performBlockAndWait:] + 264 (NSManagedObjectContext.m:4059)
46 Fhetch 0x00000001006df868 FHChatTableViewController.ensureMessageIsRead(message:) + 1032 (ChatTableViewController+CoreData.swift:658)
47 Fhetch 0x00000001006dc9d0 closure #1 in FHChatTableViewController.directlyInsertRows(for:reloadTable:resortTable:) + 3640 (ChatTableViewController+CoreData.swift:315)
48 Fhetch 0x00000001006e0730 thunk for #callee_guaranteed (#guaranteed FHContentMO) -> (#owned FHChatCellContentData?, #error #owned Error) + 2000688 (<compiler-generated>:0)
49 Fhetch 0x00000001006e4a28 partial apply for thunk for #callee_guaranteed (#guaranteed FHContentMO) -> (#owned FHChatCellContentData?, #error #owned Error) + 2017832 (<compiler-generated>:0)
50 libswiftCore.dylib 0x00000001c9e48ce0 Sequence.compactMap<A>(_:) + 1224 (SequenceAlgorithms.swift:807)
51 Fhetch 0x00000001006db6ac FHChatTableViewController.directlyInsertRows(for:reloadTable:resortTable:) + 276 (ChatTableViewController+CoreData.swift:289)
52 Fhetch 0x00000001006d80b8 FHChatTableViewController.updateRows(for:) + 1448 (ChatTableViewController+CoreData.swift:568)
53 Fhetch 0x00000001006d6ae8 FHChatTableViewController.processCoreDataNotification(_:) + 7964 (ChatTableViewController+CoreData.swift:108)
54 Fhetch 0x00000001006d45ac closure #1 in FHChatTableViewController.setupCoreDataNotifications() + 1588 (ChatTableViewController+CoreData.swift:38)
55 Fhetch 0x00000001005d8360 thunk for #escaping #callee_guaranteed (#in_guaranteed Notification) -> () + 918368 (<compiler-generated>:0)
56 Foundation 0x00000001c69ee564 -[__NSObserver _doit:] + 348 (NSNotification.m:327)
57 CoreFoundation 0x00000001c51f7324 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 28 (CFNotificationCenter.c:652)
58 CoreFoundation 0x00000001c5293ac4 ___CFXRegistrationPost_block_invoke + 52 (CFNotificationCenter.c:173)
59 CoreFoundation 0x00000001c5266cc0 _CFXRegistrationPost + 456 (CFNotificationCenter.c:199)
60 CoreFoundation 0x00000001c520d39c _CFXNotificationPost + 728 (CFNotificationCenter.c:1147)
61 Foundation 0x00000001c69d4704 -[NSNotificationCenter postNotificationName:object:userInfo:] + 96 (NSNotification.m:560)
62 CoreData 0x00000001cc9e2628 -[NSManagedObjectContext _postObjectsDidChangeNotificationWithUserInfo:] + 468 (NSManagedObjectContext.m:8290)
63 CoreData 0x00000001cc9c87e4 -[NSManagedObjectContext _createAndPostChangeNotification:deletions:updates:refreshes:deferrals:wasMerge:] + 1576 (NSManagedObjectContext.m:7922)
64 CoreData 0x00000001cc9bfbbc -[NSManagedObjectContext _postRefreshedObjectsNotificationAndClearList] + 200 (NSManagedObjectContext.m:7471)
65 CoreData 0x00000001cc9be278 -[NSManagedObjectContext _processRecentChanges:] + 108 (NSManagedObjectContext.m:7550)
66 CoreData 0x00000001cc9bf8b0 developerSubmittedBlockToNSManagedObjectContextPerform + 280 (NSManagedObjectContext.m:3949)
67 libdispatch.dylib 0x00000001c4ecca2c _dispatch_client_callout + 20 (object.m:560)
68 libdispatch.dylib 0x00000001c4edaf48 _dispatch_main_queue_drain + 928 (inline_internal.h:2622)
69 libdispatch.dylib 0x00000001c4edab98 _dispatch_main_queue_callback_4CF + 44 (queue.c:7770)
70 CoreFoundation 0x00000001c521e2f0 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 (CFRunLoop.c:1795)
71 CoreFoundation 0x00000001c51d81f4 __CFRunLoopRun + 2532 (CFRunLoop.c:3144)
72 CoreFoundation 0x00000001c51eb6b8 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3268)
73 GraphicsServices 0x00000001e1285374 GSEventRunModal + 164 (GSEvent.c:2200)
74 UIKitCore 0x00000001c7b50e88 -[UIApplication _run] + 1100 (UIApplication.m:3511)
75 UIKitCore 0x00000001c78d25ec UIApplicationMain + 364 (UIApplication.m:5064)
76 Fhetch 0x00000001005ca818 main + 64 (AppDelegate.swift:31)
77 dyld 0x0000000100fc1ce4 start + 520 (dyldMain.cpp:879)
Thread 7 name:
Thread 7:
0 libsystem_kernel.dylib 0x00000001fcd281a4 select$DARWIN_EXTSN + 8
1 CoreFoundation 0x00000001c5277658 __CFSocketManager + 644 (CFSocket.c:1343)
2 libsystem_pthread.dylib 0x00000002369969ac _pthread_start + 148 (pthread.c:891)
3 libsystem_pthread.dylib 0x0000000236995e68 thread_start + 8
Thread 9 name:
Thread 9:
0 libsystem_kernel.dylib 0x00000001fcd28178 __ulock_wait + 8
1 libsystem_platform.dylib 0x000000023698d9ac _os_unfair_lock_lock_slow + 172 (lock.c:578)
2 FHKit 0x00000001016ccad8 lock(_:) + 648 (ThreadAndQueueManagement.swift:144)
3 FHKit 0x00000001016cde20 static FHThreadManager.synchronized<A>(_:shouldLogInfo:_:) + 864 (ThreadAndQueueManagement.swift:192)
4 FHKit 0x00000001016ca460 synchronized<A>(_:shouldLogInfo:_:) + 88 (ThreadAndQueueManagement.swift:211)
5 FHKit 0x000000010186c0e4 static FHActionManager.process(submittableUserAction:fromContext:) + 476 (ActionManager+Processing.swift:439)
6 FHKit 0x0000000101867638 static FHActionManager.process<A>(actionForRecord:fromContext:) + 680 (ActionManager+Processing.swift:390)
7 FHKit 0x0000000101866e4c static FHActionManager.process(action:forContent:fromContext:bypassingServerInteraction:withTrustedTimestamps:) + 2666060 (ActionManager+Processing.swift:26)
8 FHKit 0x00000001019d4790 closure #1 in FHUserNotificationMessageArrivedInfo.merge(intoContext:) + 5512 (NewMessageArrived.swift:118)
9 FHKit 0x000000010166124c thunk for #callee_guaranteed () -> () + 20 (<compiler-generated>:0)
10 FHKit 0x00000001016612ac thunk for #escaping #callee_guaranteed () -> () + 28 (<compiler-generated>:0)
11 CoreData 0x00000001cc9bf834 developerSubmittedBlockToNSManagedObjectContextPerform + 156 (NSManagedObjectContext.m:3942)
12 libdispatch.dylib 0x00000001c4ecca2c _dispatch_client_callout + 20 (object.m:560)
13 libdispatch.dylib 0x00000001c4edc0b8 _dispatch_sync_invoke_and_complete_recurse + 64 (queue.c:1028)
14 libdispatch.dylib 0x00000001c4edbb44 _dispatch_sync_f_slow + 172 (queue.c:1785)
15 CoreData 0x00000001cc9bfa94 -[NSManagedObjectContext performBlockAndWait:] + 264 (NSManagedObjectContext.m:4059)
16 FHKit 0x00000001019d2ff0 FHUserNotificationMessageArrivedInfo.merge(intoContext:) + 1364 (NewMessageArrived.swift:48)
17 Fhetch 0x0000000100547994 FHChatTableViewController.processAnyPendingNotifications() + 326036 (ChatTableViewController.swift:214)
18 Fhetch 0x00000001005472a8 closure #1 in FHChatTableViewController.appDidBecomeActive() + 324264 (ChatTableViewController.swift:183)
19 Fhetch 0x00000001005059ac thunk for #escaping #callee_guaranteed () -> () + 52 (<compiler-generated>:0)
20 libdispatch.dylib 0x00000001c4ecae68 _dispatch_call_block_and_release + 32 (init.c:1517)
21 libdispatch.dylib 0x00000001c4ecca2c _dispatch_client_callout + 20 (object.m:560)
22 libdispatch.dylib 0x00000001c4ede280 _dispatch_root_queue_drain + 680 (inline_internal.h:2622)
23 libdispatch.dylib 0x00000001c4ede96c _dispatch_worker_thread2 + 164 (queue.c:6935)
24 libsystem_pthread.dylib 0x0000000236996080 _pthread_wqthread + 228 (pthread.c:2612)
25 libsystem_pthread.dylib 0x0000000236995e5c start_wqthread + 8
Thread 11 name:
Thread 11:
0 libsystem_kernel.dylib 0x00000001fcd27bdc kevent_id + 8
1 libdispatch.dylib 0x00000001c4eef1fc _dispatch_kq_poll + 228 (event_kevent.c:750)
2 libdispatch.dylib 0x00000001c4eefc20 _dispatch_event_loop_wait_for_ownership + 444 (event_kevent.c:2209)
3 libdispatch.dylib 0x00000001c4edbf54 __DISPATCH_WAIT_FOR_QUEUE__ + 328 (queue.c:1690)
4 libdispatch.dylib 0x00000001c4edbb28 _dispatch_sync_f_slow + 144 (queue.c:1774)
5 CoreData 0x00000001cc9bfa94 -[NSManagedObjectContext performBlockAndWait:] + 264 (NSManagedObjectContext.m:4059)
6 FHKit 0x00000001018b1034 closure #1 in static FHAPIEndpointDescribing.execute<A>(withRequestData:responseHandler:) + 10748 (EndpointDescribing.swift:308)
7 FHKit 0x00000001018b4324 partial apply for closure #1 in static FHAPIEndpointDescribing.execute<A>(withRequestData:responseHandler:) + 92 (<compiler-generated>:0)
8 FHKit 0x00000001018ab054 thunk for #escaping #callee_guaranteed (#guaranteed Data?, #guaranteed NSURLResponse?, #guaranteed Error?) -> () + 268 (<compiler-generated>:0)
9 CFNetwork 0x00000001c5a0c0bc __40-[__NSURLSessionLocal taskForClassInfo:]_block_invoke + 532 (LocalSession.mm:675)
10 CFNetwork 0x00000001c5a1d208 __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke_2 + 196 (LocalSessionTask.mm:543)
11 libdispatch.dylib 0x00000001c4ecae68 _dispatch_call_block_and_release + 32 (init.c:1517)
12 libdispatch.dylib 0x00000001c4ecca2c _dispatch_client_callout + 20 (object.m:560)
13 libdispatch.dylib 0x00000001c4ed4124 _dispatch_lane_serial_drain + 668 (inline_internal.h:2622)
14 libdispatch.dylib 0x00000001c4ed4cb4 _dispatch_lane_invoke + 444 (queue.c:3944)
15 libdispatch.dylib 0x00000001c4edf500 _dispatch_workloop_worker_thread + 648 (queue.c:6732)
16 libsystem_pthread.dylib 0x00000002369960bc _pthread_wqthread + 288 (pthread.c:2599)
17 libsystem_pthread.dylib 0x0000000236995e5c start_wqthread + 8
Thread 12:
0 libsystem_pthread.dylib 0x0000000236995e54 start_wqthread + 0
Thread 13 name:
Thread 13:
0 libsystem_kernel.dylib 0x00000001fcd28178 __ulock_wait + 8
1 libsystem_platform.dylib 0x000000023698d9ac _os_unfair_lock_lock_slow + 172 (lock.c:578)
2 FHKit 0x00000001016ccad8 lock(_:) + 648 (ThreadAndQueueManagement.swift:144)
3 FHKit 0x00000001016cde20 static FHThreadManager.synchronized<A>(_:shouldLogInfo:_:) + 864 (ThreadAndQueueManagement.swift:192)
4 FHKit 0x00000001016ca460 synchronized<A>(_:shouldLogInfo:_:) + 88 (ThreadAndQueueManagement.swift:211)
5 FHKit 0x00000001019cc8a4 static FHNetworkOperationsQueue.popNextOperation() + 124 (NetworkOperationsQueue.swift:248)
6 FHKit 0x00000001019ccd80 closure #1 in closure #1 in static FHNetworkOperationsQueue.resume() + 88 (NetworkOperationsQueue.swift:300)
7 FHKit 0x0000000101931048 thunk for #escaping #callee_guaranteed () -> () + 20 (<compiler-generated>:0)
8 FHKit 0x00000001019c330c thunk for #escaping #callee_guaranteed () -> (#out ()) + 20 (<compiler-generated>:0)
9 FHKit 0x00000001016f3130 closure #1 in static FHKeychain.Storage.runPendingBlocks() + 64 (Keychain+Storage.swift:83)
10 FHKit 0x0000000101840dd4 thunk for #escaping #callee_guaranteed () -> () + 52 (<compiler-generated>:0)
11 Foundation 0x00000001c6a0aa9c __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 24 (NSOperation.m:1545)
12 Foundation 0x00000001c6a1ce14 -[NSBlockOperation main] + 104 (NSOperation.m:1564)
13 Foundation 0x00000001c69f51c4 __NSOPERATION_IS_INVOKING_MAIN__ + 24 (NSOperation.m:2189)
14 Foundation 0x00000001c6a064e0 -[NSOperation start] + 788 (NSOperation.m:2206)
15 Foundation 0x00000001c6a09ae8 __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 24 (NSOperation.m:2220)
16 Foundation 0x00000001c6a17c90 __NSOQSchedule_f + 184 (NSOperation.m:2231)
17 libdispatch.dylib 0x00000001c4edb830 _dispatch_block_async_invoke2 + 148 (queue.c:560)
18 libdispatch.dylib 0x00000001c4ecca2c _dispatch_client_callout + 20 (object.m:560)
19 libdispatch.dylib 0x00000001c4ecfeec _dispatch_continuation_pop + 500 (inline_internal.h:2622)
20 libdispatch.dylib 0x00000001c4ecf558 _dispatch_async_redirect_invoke + 588 (queue.c:835)
21 libdispatch.dylib 0x00000001c4ede164 _dispatch_root_queue_drain + 396 (inline_internal.h:0)
22 libdispatch.dylib 0x00000001c4ede96c _dispatch_worker_thread2 + 164 (queue.c:6935)
23 libsystem_pthread.dylib 0x0000000236996080 _pthread_wqthread + 228 (pthread.c:2612)
24 libsystem_pthread.dylib 0x0000000236995e5c start_wqthread + 8
Thread 14 name:
Thread 14:
0 libsystem_kernel.dylib 0x00000001fcd28178 __ulock_wait + 8
1 libsystem_platform.dylib 0x000000023698d9ac _os_unfair_lock_lock_slow + 172 (lock.c:578)
2 FHKit 0x00000001016ccad8 lock(_:) + 648 (ThreadAndQueueManagement.swift:144)
3 FHKit 0x00000001016cde20 static FHThreadManager.synchronized<A>(_:shouldLogInfo:_:) + 864 (ThreadAndQueueManagement.swift:192)
4 FHKit 0x00000001016ca460 synchronized<A>(_:shouldLogInfo:_:) + 88 (ThreadAndQueueManagement.swift:211)
5 FHKit 0x00000001019cc8a4 static FHNetworkOperationsQueue.popNextOperation() + 124 (NetworkOperationsQueue.swift:248)
6 FHKit 0x00000001019ccd80 closure #1 in closure #1 in static FHNetworkOperationsQueue.resume() + 88 (NetworkOperationsQueue.swift:300)
7 FHKit 0x0000000101931048 thunk for #escaping #callee_guaranteed () -> () + 20 (<compiler-generated>:0)
8 FHKit 0x00000001019c330c thunk for #escaping #callee_guaranteed () -> (#out ()) + 20 (<compiler-generated>:0)
9 FHKit 0x00000001016f3130 closure #1 in static FHKeychain.Storage.runPendingBlocks() + 64 (Keychain+Storage.swift:83)
10 FHKit 0x0000000101840dd4 thunk for #escaping #callee_guaranteed () -> () + 52 (<compiler-generated>:0)
11 Foundation 0x00000001c6a0aa9c __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 24 (NSOperation.m:1545)
12 Foundation 0x00000001c6a1ce14 -[NSBlockOperation main] + 104 (NSOperation.m:1564)
13 Foundation 0x00000001c69f51c4 __NSOPERATION_IS_INVOKING_MAIN__ + 24 (NSOperation.m:2189)
14 Foundation 0x00000001c6a064e0 -[NSOperation start] + 788 (NSOperation.m:2206)
15 Foundation 0x00000001c6a09ae8 __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 24 (NSOperation.m:2220)
16 Foundation 0x00000001c6a17c90 __NSOQSchedule_f + 184 (NSOperation.m:2231)
17 libdispatch.dylib 0x00000001c4edb830 _dispatch_block_async_invoke2 + 148 (queue.c:560)
18 libdispatch.dylib 0x00000001c4ecca2c _dispatch_client_callout + 20 (object.m:560)
19 libdispatch.dylib 0x00000001c4ecfeec _dispatch_continuation_pop + 500 (inline_internal.h:2622)
20 libdispatch.dylib 0x00000001c4ecf558 _dispatch_async_redirect_invoke + 588 (queue.c:835)
21 libdispatch.dylib 0x00000001c4ede164 _dispatch_root_queue_drain + 396 (inline_internal.h:0)
22 libdispatch.dylib 0x00000001c4ede96c _dispatch_worker_thread2 + 164 (queue.c:6935)
23 libsystem_pthread.dylib 0x0000000236996080 _pthread_wqthread + 228 (pthread.c:2612)
24 libsystem_pthread.dylib 0x0000000236995e5c start_wqthread + 8
Thread 15:
0 libsystem_pthread.dylib 0x0000000236995e54 start_wqthread + 0
Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x0000000000000001 x1: 0x0000000000000000 x2: 0x0000000000000001 x3: 0x000000016f8ffb88
x4: 0x0000000000000001 x5: 0x0000000000000000 x6: 0x0000000000000000 x7: 0x0000000000000403
x8: 0x0000000000000400 x9: 0x000000021ea52580 x10: 0x0000000000000400 x11: 0x00000000000020ff
x12: 0x0000000101014660 x13: 0x001ffe2000000000 x14: 0x0000000066400000 x15: 0x000000021ead0208
x16: 0x0000000000000177 x17: 0xbb3000021ea51990 x18: 0x0000000000000000 x19: 0x0000000000000403
x20: 0x0000000000000000 x21: 0x0000000000000000 x22: 0x0000000000000001 x23: 0x000000016f8ffb88
x24: 0x0000000000000001 x25: 0x000000016f8ffb88 x26: 0x000000028080e580 x27: 0x0000000000020400
x28: 0x000000021ea52580 fp: 0x000000016f8ffb70 lr: 0x00000001c4eef1fc
sp: 0x000000016f8ffb10 pc: 0x00000001fcd27bdc cpsr: 0x1000
esr: 0x56000080 Address size fault
Can you identify which threads might be causing deadlock? maybe there is some other problem?
This is how it looks in the crashes organizer in XCode.
Any help in this regard would be much appreciated.
Thanks

Obviously, Thread 0 crashed because it did not get access to the queue used by a NSManagedObjectContext in line 5 with performBlockAndWait. The same queue has apparently also been used in the same thread at other lines with performBlockAndWait (10, 19, 45…). This is no problem, since performBlockAndWait can be called re-entrantly, see the docs.
However, it has apparently also been used by other threads with performBlockAndWait (Thread 9, line 15; Thread 11, line 5). It seems to me that one of these threads allocated some common resource that Thread 0 needs to complete its work - a deadlock.
It is not possible for me to find out what this critical resource is. Deadlocks are often hard to find.
A trivial suggestion that may break you code is to replace a performBlockAndWait by a performBlock and see if the affected thread continues running, even if the code is broken. Maybe this gives you some hint where to look for the problem.

Calling closures from notifications async fixes this. You can look at the memory graph to understand this.

Related

Fabric Crash com.apple.main-thread specialized AppDelegate

Anyone have any idea about the crash
Crashed: com.apple.main-thread
0 0x7ac30 specialized AppDelegate.updateUserSubscriptionStatus() + 4374539312 (AppDelegate.swift:4374539312)
1 0xb4a9c closure #1 in SubscribeViewController.handlePurchase(purchase:) + 4374776476 (<compiler-generated>:4374776476)
2 0x58310 thunk for #escaping #callee_guaranteed () -> () + 4374397712 (<compiler-generated>:4374397712)
3 libdispatch.dylib 0x1e6c _dispatch_call_block_and_release + 32
4 libdispatch.dylib 0x3a30 _dispatch_client_callout + 20
5 libdispatch.dylib 0x11f48 _dispatch_main_queue_drain + 928
6 libdispatch.dylib 0x11b98 _dispatch_main_queue_callback_4CF + 44
7 CoreFoundation 0x51800 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
8 CoreFoundation 0xb704 __CFRunLoopRun + 2532
9 CoreFoundation 0x1ebc8 CFRunLoopRunSpecific + 600
10 GraphicsServices 0x1374 GSEventRunModal + 164
11 UIKitCore 0x514b58 -[UIApplication _run] + 1100
12 UIKitCore 0x296090 UIApplicationMain + 364
13 0x14ad4 main + 47 (AppDelegate.swift:47)
14 ??? 0x10129dda4 (Missing)

Realm sometimes crashing in background mode

I am using background mode for downloading data from the server and storing it in Realm. I am getting weird crash reports from my users. I attached an example crash log.
private func addParseReportToDb(serverResponses: [AddNewParseReportResponse], trackedProfileRecordId: String) {
let trackedProfile = TrackedProfile.getByPrimaryKey(recordId: trackedProfileRecordId)!
for serverResponse in serverResponses {
let parseReport = ParseReport()
parseReport.biograph = serverResponse.biography
let realm = try! Realm()
try! realm.write({
realm.add(parseReport)
})
createUserFeedWithLatestReports(trackedProfile: trackedProfile)
}
}
Above method is calling from below method:
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: #escaping (UIBackgroundFetchResult) -> Void) {
let realm = try! Realm()
let tst = Test()
tst.type = "silent"
try! realm.write({
realm.add(tst)
})
let parseService = InstaParseService()
parseService.downloadLatestReports {
parseService.getUsersForFetch { status in
completionHandler(.newData)
}
}
}
parse.downloadLatestReports method calls the addParseReportToDb method.
The crash point is realm.add(parseReport)
As you can see actually I can add another object before adding the parseReport without any problem. Don't know why but that part crashes sometimes.
Crash log:
Incident Identifier: AB7B2EA0-F152-4F60-975E-5AA4FAA2CDFE
Hardware Model: iPhone10,6
Process: Insta Spy [35822]
Path: /private/var/containers/Bundle/Application/8A905DEA-41BF-4CA5-A026-1B7BF98919CC/Insta Spy.app/Insta Spy
Identifier: com.frost.instaspy
Version: 1.0.5 (6)
AppStoreTools: 13F15
AppVariant: 1:iPhone10,6:15
Beta: YES
Code Type: ARM-64 (Native)
Role: unknown
Parent Process: launchd [1]
Coalition: com.frost.instaspy [2476]
Date/Time: 2022-06-11 09:48:00.9830 +0300
Launch Time: 2022-06-11 09:47:58.7865 +0300
OS Version: iPhone OS 15.5 (19F77)
Release Type: User
Baseband Version: 5.03.01
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x18129fd0c __exceptionPreprocess + 216 (NSException.m:200)
1 libobjc.A.dylib 0x198a90ee4 objc_exception_throw + 56 (objc-exception.mm:565)
2 Insta Spy 0x102782e4c RLMAccessorContext::createObject(objc_object*, realm::CreatePolicy, bool, realm::ObjKey) + 1876 (RLMAccessor.mm:1097)
3 Insta Spy 0x1027cb3a8 RLMAddObjectToRealm + 200 (RLMObjectStore.mm:138)
4 Insta Spy 0x102767fb8 partial apply for thunk for #callee_guaranteed () -> (#error #owned Error) + 20 (<compiler-generated>:0)
5 Insta Spy 0x1029329b4 Realm.write<A>(withoutNotifying:_:) + 180 (Realm.swift:255)
6 Insta Spy 0x102767e70 specialized InstaParseService.addParseReportToDb(serverResponses:trackedProfileRecordId:) + 1068 (InstaParseService.swift:108)
7 Insta Spy 0x102764348 closure #1 in InstaParseService.downloadLatestReports(completionHandler:) + 268 (<compiler-generated>:0)
8 PromisedFuture 0x10358a368 closure #1 in Future.execute(onSuccess:onFailure:) + 288 (Future.swift:167)
9 Insta Spy 0x1027011d8 specialized closure #1 in closure #1 in static APIClient.performRequest<A>(route:) + 308
10 Insta Spy 0x102702768 partial apply for specialized closure #1 in closure #1 in static APIClient.performRequest<A>(route:) + 48 (<compiler-generated>:0)
11 Insta Spy 0x102d22e60 partial apply for closure #2 in closure #2 in closure #3 in closure #1 in DownloadRequest.response<A>(queue:responseSerializer:completionHandler:) + 136
12 Insta Spy 0x102cb6c94 thunk for #escaping #callee_guaranteed () -> () + 28 (<compiler-generated>:0)
13 libdispatch.dylib 0x180f5f094 _dispatch_call_block_and_release + 24 (init.c:1517)
14 libdispatch.dylib 0x180f60094 _dispatch_client_callout + 16 (object.m:560)
15 libdispatch.dylib 0x180f41858 _dispatch_main_queue_drain + 888 (inline_internal.h:2622)
16 libdispatch.dylib 0x180f414d0 _dispatch_main_queue_callback_4CF$VARIANT$armv81 + 36 (queue.c:7770)
17 CoreFoundation 0x18125b0c4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 (CFRunLoop.c:1795)
18 CoreFoundation 0x1812185e8 __CFRunLoopRun + 2544 (CFRunLoop.c:3144)
19 CoreFoundation 0x18122b240 CFRunLoopRunSpecific + 572 (CFRunLoop.c:3268)
20 GraphicsServices 0x1a1d2d988 GSEventRunModal + 160 (GSEvent.c:2200)
21 UIKitCore 0x183a2b41c -[UIApplication _run] + 1080 (UIApplication.m:3511)
22 UIKitCore 0x1837c4b88 UIApplicationMain + 336 (UIApplication.m:5064)
23 libswiftUIKit.dylib 0x197b7aee4 UIApplicationMain(_:_:_:_:) + 100 (UIKit.swift:530)
24 Insta Spy 0x1026f56f4 main + 80 (<compiler-generated>:14)
25 Insta Spy 0x1026f56f4 $main + 92 (AddTrackedProfileViewModel.swift:0)
26 Insta Spy 0x1026f56f4 main + 108
27 dyld 0x1034f83d0 start + 444 (dyldMain.cpp:879)
Thread 0 name:
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x00000001bba8fbbc __pthread_kill + 8
1 libsystem_pthread.dylib 0x00000001dc4e3854 pthread_kill + 208 (pthread.c:1668)
2 libsystem_c.dylib 0x000000018b9d50b0 __abort + 124 (abort.c:155)
3 libsystem_c.dylib 0x000000018b9806b8 abort + 136 (abort.c:126)
4 libc++abi.dylib 0x0000000198b88dd8 abort_message + 128 (abort_message.cpp:78)
5 libc++abi.dylib 0x0000000198b7955c demangling_terminate_handler() + 300 (cxa_default_handlers.cpp:71)
6 libobjc.A.dylib 0x0000000198a968f8 _objc_terminate() + 124 (objc-exception.mm:701)
7 Insta Spy 0x0000000102ef6fec FIRCLSTerminateHandler() + 340 (FIRCLSException.mm:335)
8 libc++abi.dylib 0x0000000198b88274 std::__terminate(void (*)()) + 16 (cxa_handlers.cpp:59)
9 libc++abi.dylib 0x0000000198b8821c std::terminate() + 60 (cxa_handlers.cpp:88)
10 libdispatch.dylib 0x0000000180f600a8 _dispatch_client_callout + 36 (object.m:563)
11 libdispatch.dylib 0x0000000180f41858 _dispatch_main_queue_drain + 888 (inline_internal.h:2622)
12 libdispatch.dylib 0x0000000180f414d0 _dispatch_main_queue_callback_4CF$VARIANT$armv81 + 36 (queue.c:7770)
13 CoreFoundation 0x000000018125b0c4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 (CFRunLoop.c:1795)
14 CoreFoundation 0x00000001812185e8 __CFRunLoopRun + 2544 (CFRunLoop.c:3144)
15 CoreFoundation 0x000000018122b240 CFRunLoopRunSpecific + 572 (CFRunLoop.c:3268)
16 GraphicsServices 0x00000001a1d2d988 GSEventRunModal + 160 (GSEvent.c:2200)
17 UIKitCore 0x0000000183a2b41c -[UIApplication _run] + 1080 (UIApplication.m:3511)
18 UIKitCore 0x00000001837c4b88 UIApplicationMain + 336 (UIApplication.m:5064)
19 libswiftUIKit.dylib 0x0000000197b7aee4 UIApplicationMain(_:_:_:_:) + 100 (UIKit.swift:530)
20 Insta Spy 0x00000001026f56f4 main + 80 (<compiler-generated>:14)
21 Insta Spy 0x00000001026f56f4 $main + 92 (AddTrackedProfileViewModel.swift:0)
22 Insta Spy 0x00000001026f56f4 main + 108
23 dyld 0x00000001034f83d0 start + 444 (dyldMain.cpp:879)
Thread 1:
0 libsystem_pthread.dylib 0x00000001dc4d7934 start_wqthread + 0
Thread 2:
0 libsystem_pthread.dylib 0x00000001dc4d7934 start_wqthread + 0
Thread 3:
0 libsystem_pthread.dylib 0x00000001dc4d7934 start_wqthread + 0
Thread 4 name:
Thread 4:
0 libsystem_kernel.dylib 0x00000001bba8b710 fstatat64 + 8
1 libsystem_c.dylib 0x000000018b96f478 _mkpath + 152 (mkpath_np.c:57)
2 Foundation 0x000000018296e770 -[NSFileManager createDirectoryAtPath:withIntermediateDirectories:attributes:error:] + 120 (NSFileManager.m:5356)
3 Insta Spy 0x0000000102c3b2e0 __55-[GDTCORFlatFileStorage hasEventsForTarget:onComplete:]_block_invoke + 184 (GDTCORFlatFileStorage.m:382)
4 libdispatch.dylib 0x0000000180f5f094 _dispatch_call_block_and_release + 24 (init.c:1517)
5 libdispatch.dylib 0x0000000180f60094 _dispatch_client_callout + 16 (object.m:560)
6 libdispatch.dylib 0x0000000180f3b4a4 _dispatch_lane_serial_drain$VARIANT$armv81 + 600 (inline_internal.h:2622)
7 libdispatch.dylib 0x0000000180f3bf44 _dispatch_lane_invoke$VARIANT$armv81 + 388 (queue.c:3944)
8 libdispatch.dylib 0x0000000180f458e0 _dispatch_workloop_worker_thread + 608 (queue.c:6732)
9 libsystem_pthread.dylib 0x00000001dc4d7e10 _pthread_wqthread + 284 (pthread.c:2599)
10 libsystem_pthread.dylib 0x00000001dc4d793c start_wqthread + 8
Thread 5:
0 libsystem_pthread.dylib 0x00000001dc4d7934 start_wqthread + 0
Thread 6 name:
Thread 6:
0 libsystem_kernel.dylib 0x00000001bba89aac mach_msg_trap + 8
1 libsystem_kernel.dylib 0x00000001bba8a07c mach_msg + 72 (mach_msg.c:119)
2 CoreFoundation 0x0000000181213d78 __CFRunLoopServiceMachPort + 368 (CFRunLoop.c:2646)
3 CoreFoundation 0x0000000181218080 __CFRunLoopRun + 1160 (CFRunLoop.c:3000)
4 CoreFoundation 0x000000018122b240 CFRunLoopRunSpecific + 572 (CFRunLoop.c:3268)
5 Foundation 0x0000000182938efc -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 232 (NSRunLoop.m:373)
6 Foundation 0x0000000182978010 -[NSRunLoop(NSRunLoop) runUntilDate:] + 88 (NSRunLoop.m:420)
7 UIKitCore 0x00000001839aa86c -[UIEventFetcher threadMain] + 512 (UIEventFetcher.m:1167)
8 Foundation 0x0000000182985c0c __NSThread__start__ + 792 (NSThread.m:972)
9 libsystem_pthread.dylib 0x00000001dc4d9348 _pthread_start + 116 (pthread.c:891)
10 libsystem_pthread.dylib 0x00000001dc4d7948 thread_start + 8
Thread 7 name:
Thread 7:
0 libsystem_kernel.dylib 0x00000001bba89aac mach_msg_trap + 8
1 libsystem_kernel.dylib 0x00000001bba8a07c mach_msg + 72 (mach_msg.c:119)
2 Insta Spy 0x0000000102ef83f8 FIRCLSMachExceptionReadMessage + 60 (FIRCLSMachException.c:194)
3 Insta Spy 0x0000000102ef83f8 FIRCLSMachExceptionServer + 108 (FIRCLSMachException.c:170)
4 libsystem_pthread.dylib 0x00000001dc4d9348 _pthread_start + 116 (pthread.c:891)
5 libsystem_pthread.dylib 0x00000001dc4d7948 thread_start + 8
Thread 8 name:
Thread 8:
0 libsystem_kernel.dylib 0x00000001bba8b294 kevent + 8
1 Insta Spy 0x0000000102a2f218 realm::_impl::ExternalCommitHelper::listen() + 160 (external_commit_helper.cpp:220)
2 Insta Spy 0x0000000102a2fbdc operator() + 4 (external_commit_helper.cpp:176)
3 Insta Spy 0x0000000102a2fbdc _invoke<(lambda at /Users/tolgaytoklar/Library/Developer/Xcode/DerivedData/Insta_Spy-efuqnbeotewvyncxwyoycmcgayra/SourcePackages/checkouts/realm-core/src/realm/object-store/impl/apple/external_comm... + 4 (type_traits:3918)
4 Insta Spy 0x0000000102a2fbdc _thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, (lambda at /Users/tolgaytoklar/Library/Developer/Xcode/DerivedData/Insta_Spy-e... + 4 (thread:287)
5 Insta Spy 0x0000000102a2fbdc void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::_impl::ExternalCommitHelper::ExternalCom... + 52 (thread:298)
6 libsystem_pthread.dylib 0x00000001dc4d9348 _pthread_start + 116 (pthread.c:891)
7 libsystem_pthread.dylib 0x00000001dc4d7948 thread_start + 8
Thread 9 name:
Thread 9:
0 libsystem_kernel.dylib 0x00000001bba89aac mach_msg_trap + 8
1 libsystem_kernel.dylib 0x00000001bba8a07c mach_msg + 72 (mach_msg.c:119)
2 CoreFoundation 0x0000000181213d78 __CFRunLoopServiceMachPort + 368 (CFRunLoop.c:2646)
3 CoreFoundation 0x0000000181218080 __CFRunLoopRun + 1160 (CFRunLoop.c:3000)
4 CoreFoundation 0x000000018122b240 CFRunLoopRunSpecific + 572 (CFRunLoop.c:3268)
5 CFNetwork 0x0000000181c30b08 +[__CFN_CoreSchedulingSetRunnable _run:] + 428 (CoreSchedulingSet.mm:1372)
6 Foundation 0x0000000182985c0c __NSThread__start__ + 792 (NSThread.m:972)
7 libsystem_pthread.dylib 0x00000001dc4d9348 _pthread_start + 116 (pthread.c:891)
8 libsystem_pthread.dylib 0x00000001dc4d7948 thread_start + 8
Thread 10:
0 libsystem_pthread.dylib 0x00000001dc4d7934 start_wqthread + 0
Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x0000000000000000 x1: 0x0000000000000000 x2: 0x0000000000000000 x3: 0x0000000000000000
x4: 0x0000000000000000 x5: 0x0000000000989680 x6: 0x000000000000006e x7: 0xffffffff00000900
x8: 0x0000000103548580 x9: 0xd1fb99cae63401f2 x10: 0x00000000000003e8 x11: 0x000000000000000b
x12: 0x0000000000000000 x13: 0x0000000008a2f000 x14: 0x0000000000000010 x15: 0x0000000000000000
x16: 0x0000000000000148 x17: 0x0000000000000002 x18: 0x0000000000000000 x19: 0x0000000000000006
x20: 0x0000000000000103 x21: 0x0000000103548660 x22: 0x0000000000000007 x23: 0x0000000103048472
x24: 0x0000000000000000 x25: 0x0000000103548660 x26: 0x000000000000000f x27: 0x0000000000000000
x28: 0x00000002834a2280 fp: 0x000000016d70e290 lr: 0x00000001dc4e3854
sp: 0x000000016d70e270 pc: 0x00000001bba8fbbc cpsr: 0x40000000
esr: 0x56000080 Address size fault
Binary Images:
0x1026f0000 - 0x10316ffff Insta Spy arm64 <c7b80223ca0c30759a16544c17251c9b> /private/var/containers/Bundle/Application/8A905DEA-41BF-4CA5-A026-1B7BF98919CC/Insta Spy.app/Insta Spy
0x1034e0000 - 0x103533fff dyld arm64 <0912a37c959234f1938ffdbcfcd1cf2f> /usr/lib/dyld
0x103584000 - 0x10358bfff PromisedFuture arm64 <e1670c2d528c33f49d1cad6e42bdfe69> /private/var/containers/Bundle/Application/8A905DEA-41BF-4CA5-A026-1B7BF98919CC/Insta Spy.app/Frameworks/PromisedFuture.framework/PromisedFuture
0x180efc000 - 0x180f7efff libdispatch.dylib arm64 <f87efead673b3a09b7ab9c69b55a18a8> /usr/lib/system/libdispatch.dylib
0x18120d000 - 0x18164afff CoreFoundation arm64 <48cd0a807a9234ebb1408c475d135808> /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
0x1819e9000 - 0x181e79fff CFNetwork arm64 <f154f6f6f7693743a48fc4828dca4e3c> /System/Library/Frameworks/CFNetwork.framework/CFNetwork
0x182921000 - 0x182c05fff Foundation arm64 <3cb1645d719b332f9a3a9c33a9bb4b6d> /System/Library/Frameworks/Foundation.framework/Foundation
0x183546000 - 0x184cdffff UIKitCore arm64 <a84e395e0b003162b1fdb861ce41349c> /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore
0x18b961000 - 0x18b9dcfff libsystem_c.dylib arm64 <929b8c7cb9523971a688c9c4aaf0f2b6> /usr/lib/system/libsystem_c.dylib
0x197b53000 - 0x197bb2fff libswiftUIKit.dylib arm64 <ade66154967a329d839ca3a65912d3b9> /usr/lib/swift/libswiftUIKit.dylib
0x198a7c000 - 0x198ab3fff libobjc.A.dylib arm64 <57ca31b758ea36d6a442728888f336ec> /usr/lib/libobjc.A.dylib
0x198b78000 - 0x198b8efff libc++abi.dylib arm64 <f886a31d5e493b6aa361a07fedecec59> /usr/lib/libc++abi.dylib
0x1a1d2c000 - 0x1a1d34fff GraphicsServices arm64 <996d6fdae7883abeb6d6ad8e0f4cc881> /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices
0x1bba89000 - 0x1bbabcfff libsystem_kernel.dylib arm64 <09e1dcdbe2c93f7ebbfc96dec6c161da> /usr/lib/system/libsystem_kernel.dylib
0x1dc4d6000 - 0x1dc4e6fff libsystem_pthread.dylib arm64 <5190be2141d433619249bfdc03b71e36> /usr/lib/system/libsystem_pthread.dylib
EOF

_ArrayBuffer crash

It have a crash that I can't reproduce it on my phone. I call this function in DispatchQueue.concurrentPerform.
Here is my code:
public var arrayLessons: [NotesLessonDataModel] = []
...
func addLessonIfNeeded(lesson: NotesLessonDataModel) {
if lesson.isValid() == false { return }
for item in self.arrayLessons {
if lesson.id == item.id {
return
}
}
self.arrayLessons.append(lesson)
}
...
DispatchQueue.concurrentPerform(iterations: array.count) { (index) in
requestGroup.enter()
// Callback function
self.addLessonIfNeeded(lesson: item)
requestGroup.leave()
}
Here is the firebase crash report:
Crashed: com.apple.root.user-initiated-qos
0 libswiftCore.dylib 0x383c88 _swift_release_dealloc + 24
1 Pocket Papers 0x111594 specialized _ArrayBuffer._consumeAndCreateNew(bufferIsUnique:minimumCapacity:growForAppend:) + 4339750292
2 Pocket Papers 0x91bdc PPNotesManager.addLessonIfNeeded(lesson:) + 4339227612 (<compiler-generated>:4339227612)
3 Pocket Papers 0x927f4 closure #1 in PPNotesManager.getLessonsFromSections(_:exam:completion:) + 146 (PPNotesManager.swift:146)
4 libswiftDispatch.dylib 0x5558 partial apply for thunk for #callee_guaranteed (#unowned Int) -> () + 28
5 libswiftDispatch.dylib 0x5584 thunk for #escaping #callee_guaranteed (#unowned Int) -> () + 32
6 libdispatch.dylib 0x4860 _dispatch_client_callout2 + 20
7 libdispatch.dylib 0x18d7c _dispatch_apply_invoke_and_wait + 160
8 libdispatch.dylib 0x18790 dispatch_apply_f + 728
9 libswiftDispatch.dylib 0x54c8 static OS_dispatch_queue.concurrentPerform(iterations:execute:) + 284
10 Pocket Papers 0xa5e7c closure #1 in NoteViewController.requestLessonDetails() + 161 (PPNotesManager.swift:161)
11 Pocket Papers 0xc240 thunk for #escaping #callee_guaranteed () -> () + 4338680384 (<compiler-generated>:4338680384)
12 libdispatch.dylib 0x2a84 _dispatch_call_block_and_release + 32
13 libdispatch.dylib 0x481c _dispatch_client_callout + 20
14 libdispatch.dylib 0x7968 _dispatch_queue_override_invoke + 756
15 libdispatch.dylib 0x15fe0 _dispatch_root_queue_drain + 388
16 libdispatch.dylib 0x167d8 _dispatch_worker_thread2 + 112
17 libsystem_pthread.dylib 0x3768 _pthread_wqthread + 216
18 libsystem_pthread.dylib 0xa74c start_wqthread + 8

IOS Unknown crash :- BUG IN CLIENT OF LIBPLATFORM: Trying to recursively lock an os_unfair_lock

Here is the code where the crash had occurred :-
private func dispatchMessageImmediately(topicName : String, mqttMessage : MQTTMessage){
AppDelegate.getAppDelegate().log.debug("Message: \(String(describing: mqttMessage.payloadString))")
let listener = self.topicToListenerMap?[topicName]
if listener != nil {
DispatchQueue.main.async(execute: { () -> Void in
MessageDispatchUtils.dispatchMessageToListeners(topicName: topicName, mqttMessage: mqttMessage, topicListener: listener!)
})
}
}
The Xcode version I am using is 9.3. My os version is iOS 11.4.1 Device is iPhone 5s. The crash is caused in libswift.dylib
Here is the crash report for the crash.Any help? Thanks in advance
Crashed: com.apple.main-thread
0 libsystem_platform.dylib 0x18358de38 _os_unfair_lock_recursive_abort + 36
1 libsystem_platform.dylib 0x18358ebb8 _os_unfair_lock_lock_slow + 264
2 libobjc.A.dylib 0x182b45720 objc_object::sidetable_clearDeallocating() + 104
3 libobjc.A.dylib 0x182b349d8 objc_destructInstance + 140
4 libswiftCore.dylib 0x10263ec0c swift_deallocClassInstance + 32
5 libswiftCore.dylib 0x10263eb4c _swift_release_dealloc + 28
6 Razorpay 0x1020f09b0 _T08Razorpay0A13UtilFunctionsC24handleUnhandledExceptionys5Int32V16havingSignalCode_SS03andI4NametFZTf4nnd_n + 248
7 libsystem_platform.dylib 0x183590b48 _sigtramp + 36
8 libobjc.A.dylib 0x182b45740 objc_object::sidetable_clearDeallocating() + 136
9 libobjc.A.dylib 0x182b45740 objc_object::sidetable_clearDeallocating() + 136
10 libobjc.A.dylib 0x182b349d8 objc_destructInstance + 140
11 libswiftCore.dylib 0x10263ec0c swift_deallocClassInstance + 32
12 libswiftCore.dylib 0x10263eb4c _swift_release_dealloc + 28
13 libswiftCore.dylib 0x1025750ec specialized String.debugDescription.getter + 4580
14 libswiftCore.dylib 0x1024bd66c protocol witness for CustomDebugStringConvertible.debugDescription.getter in conformance String + 290904
15 libswiftCore.dylib 0x1023da008 _debugPrint_unlocked<A, B>(_:_:) + 252544
16 libswiftCore.dylib 0x10257bc04 specialized _debugPrint<A>(_:separator:terminator:to:) + 31996
17 libswiftCore.dylib 0x10245a8fc Optional.debugDescription.getter + 68296
18 libswiftCore.dylib 0x10245aa4c protocol witness for CustomStringConvertible.description.getter in conformance <A> A! + 68632
19 libswiftCore.dylib 0x10257bf44 specialized _print_unlocked<A, B>(_:_:) + 32828
20 Quickride 0x10090c37c implicit closure #1 in EventServiceProxy.dispatchMessageImmediately(topicName:mqttMessage:) (EventServiceProxy.swift:238)
21 Quickride 0x1009186c4 partial apply for implicit closure #1 in EventServiceProxy.onNewMessageArrived(mqttMessage:) + 4314498756
22 XCGLogger 0x1021b86f4 _T09XCGLoggerAAC5loglnyAB5LevelO_SS12functionNameSS04fileE0Si10lineNumbers10DictionaryVySSypG8userInfoypSgyc7closuretFTf4ngXgXnggn_n + 232
23 XCGLogger 0x1021b3bac _T09XCGLoggerAAC7verboseyypSgyXK_s12StaticStringV12functionNameAF04fileF0Si10lineNumbers10DictionaryVySSypG8userInfotFTm + 500
24 XCGLogger 0x1021b2aa8 _T09XCGLoggerAAC5debugyypSgyXK_s12StaticStringV12functionNameAF04fileF0Si10lineNumbers10DictionaryVySSypG8userInfotF + 32
25 Quickride 0x100915144 specialized EventServiceProxy.dispatchMessageImmediately(topicName:mqttMessage:) (EventServiceProxy.swift:238)
26 Quickride 0x100916918 specialized EventServiceProxy.onNewMessageArrived(mqttMessage:) (EventServiceProxy.swift:145)
27 Quickride 0x10090d8c8 protocol witness for MqttCallback.onNewMessageArrived(mqttMessage:) in conformance EventServiceProxy (EventServiceProxy.swift)
28 Quickride 0x100cf309c specialized closure #1 in closure #4 in EventServiceConnection.createMqttConfig() (EventServiceConnection.swift:100)
29 Quickride 0x100cf29f4 partial apply for closure #1 in closure #4 in EventServiceConnection.createMqttConfig() (EventServiceConnection.swift)
30 Quickride 0x1008c19fc thunk for #callee_owned () -> () (RideManagementModuleSessonHandler.swift)
31 libdispatch.dylib 0x183260aa0 _dispatch_call_block_and_release + 24
32 libdispatch.dylib 0x183260a60 _dispatch_client_callout + 16
33 libdispatch.dylib 0x18326d65c _dispatch_main_queue_callback_4CF$VARIANT$mp + 1012
34 CoreFoundation 0x183917070 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
35 CoreFoundation 0x183914bc8 __CFRunLoopRun + 2272
36 CoreFoundation 0x183834da8 CFRunLoopRunSpecific + 552
37 GraphicsServices 0x18581a020 GSEventRunModal + 100
38 UIKit 0x18d854758 UIApplicationMain + 236
39 Quickride 0x1007d4bf0 main (AppDelegate.swift:26)
40 libdyld.dylib 0x1832c5fc0 start + 4

NSInvalidArgumentException: -[MKMapItem encodeWithCoder:]: unrecognized selector sent to instance 0x17034bfd0

I got a crash report, which is about unrecognized selector sent to instance when saving MKMapItem into Data Store. According to MKMapItem documents(MKMapItem Document), it conforms to NSSecureCoding, which means that it should have no problem to save it into an NSManagedObject instance. it looks fine on ios 11 version, as i didn't receive crash report from the device with this version. Also, I walkthrough the feature that possibly saving MKMapItem on my phone. the context does save the NKMapItem into data store and the feature is working. Since my phone is running IOS 11, so I am thinking it could be about the version system??
Please correct me if misunderstand something.
Here is the crash report.
OS Version: iPhone OS 10.3.3 (14G60)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x181646fe0 __exceptionPreprocess + 124 (NSException.m:165)
1 libobjc.A.dylib 0x1800a8538 objc_exception_throw + 56 (objc-exception.mm:521)
2 CoreFoundation 0x18164def4 -[NSObject(NSObject) doesNotRecognizeSelector:] + 140 (NSObject.m:328)
3 CoreFoundation 0x18164af54 ___forwarding___ + 916 (NSForwarding.m:3126)
4 CoreFoundation 0x181546d4c _CF_forwarding_prep_0 + 92
5 Foundation 0x18209afd4 _encodeObject + 1176 (NSKeyedArchiver.m:873)
6 Foundation 0x1820a1e9c +[NSKeyedArchiver archivedDataWithRootObject:] + 168 (NSKeyedArchiver.m:421)
7 CoreData 0x18391ae28 -[NSSQLiteConnection execute] + 1952 (NSSQLiteConnection.m:4165)
8 CoreData 0x1839520e4 -[NSSQLiteConnection insertRow:] + 456 (NSSQLiteConnection.m:2966)
9 CoreData 0x183ae3df8 _writeChangesForSaveRequest + 824 (NSSQLCore_Functions.m:1561)
10 CoreData 0x183ae5584 _executeSaveChangesRequest + 388 (NSSQLCore_Functions.m:1622)
11 CoreData 0x183adb5f0 -[NSSQLSaveChangesRequestContext executeRequestUsingConnection:] + 44 (NSSQLSaveChangesRequestContext.m:103)
12 CoreData 0x1839f30c4 __52-[NSSQLDefaultConnectionManager handleStoreRequest:]_block_invoke + 256 (NSSQLConnectionManager.m:305)
13 libdispatch.dylib 0x1804fe9a0 _dispatch_client_callout + 16 (object.m:473)
14 libdispatch.dylib 0x18050bee0 _dispatch_barrier_sync_f_invoke + 84 (queue.c:3446)
15 CoreData 0x1839f2f64 -[NSSQLDefaultConnectionManager handleStoreRequest:] + 208 (NSSQLConnectionManager.m:290)
16 CoreData 0x183ab5824 -[NSSQLCoreDispatchManager routeStoreRequest:] + 272 (NSSQLCoreDispatchManager.m:56)
17 CoreData 0x183a2075c -[NSSQLCore dispatchRequest:withRetries:] + 236 (NSSQLCore.m:2726)
18 CoreData 0x183a1c578 -[NSSQLCore processSaveChanges:forContext:] + 200 (NSSQLCore.m:1569)
19 CoreData 0x183920f10 -[NSSQLCore executeRequest:withContext:error:] + 724 (NSSQLCore.m:1923)
20 CoreData 0x1839ff84c __65-[NSPersistentStoreCoordinator executeRequest:withContext:error:]_block_invoke + 3492 (NSPersistentStoreCoordinator.m:2820)
21 CoreData 0x1839f80f0 -[NSPersistentStoreCoordinator _routeHeavyweightBlock:] + 276 (NSPersistentStoreCoordinator.m:586)
22 CoreData 0x183920adc -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 408 (NSPersistentStoreCoordinator.m:2706)
23 CoreData 0x18394197c -[NSManagedObjectContext save:] + 2548 (NSManagedObjectContext.m:1419)
24 myappName 0x10009421c coreDataManager.saveContext() + 92 (coreDataManager.swift:514)
25 myappName 0x1000b5970 closure #1 in eventUpdateManager.observeValue(forKeyPath:of:change:context:) + 64 (eventUpdateManager.swift:138)
26 myappName 0x100124924 thunk for #escaping #callee_guaranteed () -> () + 36 (customAnimationController.swift:0)
27 libdispatch.dylib 0x1804fe9e0 _dispatch_call_block_and_release + 24 (init.c:963)
28 libdispatch.dylib 0x1804fe9a0 _dispatch_client_callout + 16 (object.m:473)
29 libdispatch.dylib 0x1805035e8 _dispatch_main_queue_callback_4CF + 996 (inline_internal.h:2431)
30 CoreFoundation 0x1815f50c8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 (CFRunLoop.c:1793)
31 CoreFoundation 0x1815f2ce4 __CFRunLoopRun + 1572 (CFRunLoop.c:3004)
32 CoreFoundation 0x181522da4 CFRunLoopRunSpecific + 424 (CFRunLoop.c:3113)
33 GraphicsServices 0x182f8d074 GSEventRunModal + 100 (GSEvent.c:2245)
34 UIKit 0x1877ddc9c UIApplicationMain + 208 (UIApplication.m:4089)
35 myappName 0x10005da1c main + 56 (receiptCollectionViewCell.swift:18)
36 libdyld.dylib 0x18053159c start + 4
Thread 0 name:
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x0000000180641014 __pthread_kill + 8
1 libsystem_pthread.dylib 0x000000018070b264 pthread_kill + 112 (pthread.c:1366)
2 libsystem_c.dylib 0x00000001805b59c4 abort + 140 (abort.c:91)
3 myappName 0x0000000100170ac8 uncaught_exception_handler + 72
4 CoreFoundation 0x0000000181647354 __handleUncaughtException + 628 (NSException.m:218)
5 libobjc.A.dylib 0x00000001800a8814 _objc_terminate() + 112 (objc-exception.mm:656)
6 myappName 0x0000000100155408 MSCrashesUncaughtCXXTerminateHandler() + 732 (MSCrashesCXXExceptionHandler.mm:171)
7 libc++abi.dylib 0x00000001800975d4 std::__terminate(void (*)()) + 16 (cxa_handlers.cpp:68)
8 libc++abi.dylib 0x00000001800971a8 __cxa_rethrow + 144 (cxa_exception.cpp:584)
9 libobjc.A.dylib 0x00000001800a86f8 objc_exception_rethrow + 44 (objc-exception.mm:559)
10 CoreData 0x0000000183941cb0 -[NSManagedObjectContext save:] + 3368 (NSManagedObjectContext.m:1548)
11 myappName 0x000000010009421c coreDataManager.saveContext() + 92 (coreDataManager.swift:514)
12 myappName 0x00000001000b5970 closure #1 in eventUpdateManager.observeValue(forKeyPath:of:change:context:) + 64 (eventUpdateManager.swift:138)
13 myappName 0x0000000100124924 thunk for #escaping #callee_guaranteed () -> () + 36 (customAnimationController.swift:0)
14 libdispatch.dylib 0x00000001804fe9e0 _dispatch_call_block_and_release + 24 (init.c:963)
15 libdispatch.dylib 0x00000001804fe9a0 _dispatch_client_callout + 16 (object.m:473)
16 libdispatch.dylib 0x00000001805035e8 _dispatch_main_queue_callback_4CF + 996 (inline_internal.h:2431)
17 CoreFoundation 0x00000001815f50c8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 (CFRunLoop.c:1793)
18 CoreFoundation 0x00000001815f2ce4 __CFRunLoopRun + 1572 (CFRunLoop.c:3004)
19 CoreFoundation 0x0000000181522da4 CFRunLoopRunSpecific + 424 (CFRunLoop.c:3113)
20 GraphicsServices 0x0000000182f8d074 GSEventRunModal + 100 (GSEvent.c:2245)
21 UIKit 0x00000001877ddc9c UIApplicationMain + 208 (UIApplication.m:4089)
22 myappName 0x000000010005da1c main + 56 (receiptCollectionViewCell.swift:18)
23 libdyld.dylib 0x000000018053159c start + 4

Resources