_ArrayBuffer crash - ios

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

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)

Crash I cannot resolve since a long time

This is what appear in crash log for crashlytics:
Crashed: com.apple.main-thread
0 FieldService 0x665cc specialized MonthNameFormater.stringForValue(_:axis:) + 4304774604 (GraphViewController.swift:4304774604)
1 FieldService 0x5fd74 #objc MonthNameFormater.stringForValue(_:axis:) + 4304747892 (:4304747892)
2 Charts 0xcc4c AxisBase.getFormattedLabel(_:) + 149 (AxisBase.swift:149)
3 Charts 0xcaa8 AxisBase.getLongestLabel() + 138 (AxisBase.swift:138)
4 Charts 0xb0c78 XAxisRenderer.computeSize() + 158 (XAxisRenderer.swift:158)
5 Charts 0xb0b3c XAxisRenderer.computeAxisValues(min:max:) + 154 (XAxisRenderer.swift:154)
6 Charts 0x1cb9c BarLineChartViewBase.notifyDataSetChanged() + 592 (:592)
7 Charts 0x57ee8 ChartViewBase.data.didset + 656 (:656)
8 Charts 0x54750 ChartViewBase.data.setter + 84 (:84)
9 FieldService 0x62368 GraphViewController.updateGraph() + 4304757608 (:4304757608)
10 FieldService 0x610e0 closure #1 in closure #1 in GraphViewController.viewDidLoad() + 4304752864
11 FieldService 0xb2000 thunk for #escaping #callee_guaranteed () -> () + 4305084416 (:4305084416)
12 libdispatch.dylib 0x1e6c _dispatch_call_block_and_release + 32
13 libdispatch.dylib 0x3a30 _dispatch_client_callout + 20
14 libdispatch.dylib 0x11f48 _dispatch_main_queue_drain + 928
15 libdispatch.dylib 0x11b98 _dispatch_main_queue_callback_4CF + 44
16 CoreFoundation 0x51800 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
17 CoreFoundation 0xb704 __CFRunLoopRun + 2532
18 CoreFoundation 0x1ebc8 CFRunLoopRunSpecific + 600
19 GraphicsServices 0x1374 GSEventRunModal + 164
20 UIKitCore 0x514b58 -[UIApplication _run] + 1100
21 UIKitCore 0x296098 UIApplicationMain + 364
22 FieldService 0x6b74 main + 20 (AppDelegate.swift:20)
23 ??? 0x1018a9da4 (Missing)
As you can see, a lot of users is impacted with it.
And this is my class called MonthNameFormatter. What and where is the issue?
import Charts
import CoreData
class MonthNameFormater: IndexAxisValueFormatter {
override func stringForValue(_ value: Double, axis: AxisBase?) -> String {
let symbols = Calendar.localizedCurrent.shortMonthSymbols
let index = min(Options.shared.isTheocraticYearEnabled ? (Int(value) + 8) % 12 : Int(value), 11)
guard symbols.count == 12 else {
return "-"
}
return symbols[index]
}
}
Where do I use it in code?
private let chartView: LineChartView = {
let view = LineChartView()
view.xAxis.labelPosition = .bottom
view.rightAxis.enabled = false
view.borderLineWidth = 0
view.xAxis.valueFormatter = MonthNameFormater()
view.xAxis.granularity = 1
view.isUserInteractionEnabled = false
return view
}()
This is an info from Xcode
Thread 0 name:
Thread 0 Crashed:
0 FieldService 0x0000000104f665cc Swift runtime failure: Index out of range + 0 (:0)
1 FieldService 0x0000000104f665cc specialized _ArrayBuffer._checkInoutAndNativeTypeCheckedBounds(_:wasNativeTypeChecked:) + 0 (:0)
2 FieldService 0x0000000104f665cc specialized Array._checkSubscript(_:wasNativeTypeChecked:) + 0 (GraphViewController.swift:0)
3 FieldService 0x0000000104f665cc specialized Array.subscript.getter + 0 (GraphViewController.swift:17)
4 FieldService 0x0000000104f665cc specialized MonthNameFormater.stringForValue(_:axis:) + 744
5 FieldService 0x0000000104f66498 specialized MonthNameFormater.stringForValue(_:axis:) + 436 (:0)
6 FieldService 0x0000000104f5fd74 MonthNameFormater.stringForValue(_:axis:) + 4 (:0)
7 FieldService 0x0000000104f5fd74 #objc MonthNameFormater.stringForValue(_:axis:) + 16
8 Charts 0x0000000106b88c4c AxisBase.getFormattedLabel(_:) + 160 (AxisBase.swift:149)
9 Charts 0x0000000106b88aa8 implicit closure #2 in implicit closure #1 in AxisBase.getLongestLabel() + 8 (AxisBase.swift:138)
10 Charts 0x0000000106b88aa8 thunk for #escaping #callee_guaranteed (#unowned Int) -> (#owned String) + 8 (:0)
11 Charts 0x0000000106b88aa8 specialized Optional.map(_:) + 8 (:0)
12 Charts 0x0000000106b88aa8 specialized LazyMapSequence.Iterator.next() + 8 (:0)
13 Charts 0x0000000106b88aa8 specialized protocol witness for IteratorProtocol.next() in conformance LazyMapSequence.Iterator + 8 (:0)
I am not sure if it is exactly the same bug, but it is also related to MonthNameFormater.
Given
Swift runtime failure: Index out of range + 0 (:0)
I suspect the crash happens at return symbols[index] - make sure index is in fact a valid index in symbols.

How to fix EXC_CRASH (SIGKILL) watchdog termination?

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.

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

Swift iOS EKEventStore : Fetching atendees from EKEvent causes sometimes to crash with NSInvalidArgumentException

I try to load all Calendar events by using block and sometimes (0.5% rate) I get NSInvalidArgumentException that causes to crash:
var allCals = _eventStore.calendarsForEntityType(EKEntityTypeEvent)
var predicate:NSPredicate! = _eventStore.predicateForEventsWithStartDate(yearsAgo, endDate:toAgo, calendars:allCals)
_eventStore.enumerateEventsMatchingPredicate(predicate, usingBlock:{
(event:EKEvent!, stop:UnsafeMutablePointer<ObjCBool>) in
if (event.title != nil
&& event.calendar != nil
&& event.calendar.calendarIdentifier != nil
&& event.lastModifiedDate != nil
){
if event.attendees != nil{ // < -- SOMETIMES LEADS TO CRASH!!
//...
}
else{ // standalone
//...
}
}
//......
})// end block
Full stack trace: [thread crash + Exception]
Thread : Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x2917649f __exceptionPreprocess + 126
1 libobjc.A.dylib 0x36970c8b objc_exception_throw + 38
2 CoreFoundation 0x29096291 -[__NSSetM addObject:] + 608
3 EventKit 0x29b4eacf -[EKPersistentObject primitiveRelationValueForKey:] + 502
4 Foundation 0x29dc1617 -[NSObject(NSKeyValueCoding) valueForKey:] + 202
5 EventKit 0x29b5afc5 -[EKObjectToManyRelation _loadedItems] + 120
6 EventKit 0x29b5aef3 -[EKObjectToManyRelation _effectiveItems] + 102
7 EventKit 0x29b5ae69 -[EKObjectToManyRelation items] + 20
8 EventKit 0x29b5d179 -[EKCalendarItem attendees] + 36
9 MyApp 0x000d8c78 _TTSf2n_n_n_n_n_d_i_n_n___TFFC8MyApp17WmBuildGroupsTask14doInBackgroundFS0_FT_T_U_FTGSqCSo7EKEvent_GVSs20UnsafeMutablePointerV10ObjectiveC8ObjCBool__T_ (WmBuildGroupsTask.swift:421)
10 MyApp 0x000d3f3c _TPA__TTSf2n_n_n_n_n_d_i_n_n___TFFC8MyApp17WmBuildGroupsTask14doInBackgroundFS0_FT_T_U_FTGSqCSo7EKEvent_GVSs20UnsafeMutablePointerV10ObjectiveC8ObjCBool__T_ (WmBuildGroupsTask.swift)
11 MyApp 0x000d96b8 reabstraction thunk helper from #callee_owned (#owned Swift.ImplicitlyUnwrappedOptional<ObjectiveC.EKEvent>, #unowned Swift.UnsafeMutablePointer<ObjectiveC.ObjCBool>) -> (#unowned ()) to #callee_unowned #objc_block (#unowned Swift.ImplicitlyUnwrappedOptional<ObjectiveC.EKEvent>, #unowned Swift.UnsafeMutablePointer<ObjectiveC.ObjCBool>) -> (#unowned ()) (WmBuildGroupsTask.swift)
12 EventKit 0x29ba72a7 __60-[EKEventStore enumerateEventsMatchingPredicate:usingBlock:]_block_invoke + 130
13 EventKit 0x29bad6af __41-[EKPredicateSearch startWithCompletion:]_block_invoke_2 + 690
14 libdispatch.dylib 0x36ed07bb _dispatch_call_block_and_release + 10
15 libdispatch.dylib 0x36ed9dab _dispatch_root_queue_drain + 866
16 libdispatch.dylib 0x36edacd7 _dispatch_worker_thread3 + 94
17 libsystem_pthread.dylib 0x37031e31 _pthread_wqthread + 668
18 libsystem_pthread.dylib 0x37031b84 start_wqthread + 8
Thread : Crashed: com.apple.root.default-qos
0 libsystem_kernel.dylib 0x36fb6dfc __pthread_kill + 8
1 libsystem_pthread.dylib 0x37034d37 pthread_kill + 62
2 libsystem_c.dylib 0x36f56909 abort + 76
3 libc++abi.dylib 0x362919c9 __cxa_bad_cast
4 libc++abi.dylib 0x362ab671 default_unexpected_handler()
5 libobjc.A.dylib 0x36970f25 _objc_terminate() + 192
6 libc++abi.dylib 0x362a8de3 std::__terminate(void (*)()) + 78
7 libc++abi.dylib 0x362a85a9 __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*)
8 libobjc.A.dylib 0x36970d5f objc_exception_throw + 250
9 CoreFoundation 0x29096291 -[__NSSetM addObject:] + 608
10 EventKit 0x29b4eacf -[EKPersistentObject primitiveRelationValueForKey:] + 502
11 Foundation 0x29dc1617 -[NSObject(NSKeyValueCoding) valueForKey:] + 202
12 EventKit 0x29b5afc5 -[EKObjectToManyRelation _loadedItems] + 120
13 EventKit 0x29b5aef3 -[EKObjectToManyRelation _effectiveItems] + 102
14 EventKit 0x29b5ae69 -[EKObjectToManyRelation items] + 20
15 EventKit 0x29b5d179 -[EKCalendarItem attendees] + 36
16 MyApp 0x000d8c78 _TTSf2n_n_n_n_n_d_i_n_n___TFFC8MyApp17WmBuildGroupsTask14doInBackgroundFS0_FT_T_U_FTGSqCSo7EKEvent_GVSs20UnsafeMutablePointerV10ObjectiveC8ObjCBool__T_ (WmBuildGroupsTask.swift:421)
17 MyApp 0x000d3f3c _TPA__TTSf2n_n_n_n_n_d_i_n_n___TFFC8MyApp17WmBuildGroupsTask14doInBackgroundFS0_FT_T_U_FTGSqCSo7EKEvent_GVSs20UnsafeMutablePointerV10ObjectiveC8ObjCBool__T_ (WmBuildGroupsTask.swift)
18 MyApp 0x000d96b8 reabstraction thunk helper from #callee_owned (#owned Swift.ImplicitlyUnwrappedOptional<ObjectiveC.EKEvent>, #unowned Swift.UnsafeMutablePointer<ObjectiveC.ObjCBool>) -> (#unowned ()) to #callee_unowned #objc_block (#unowned Swift.ImplicitlyUnwrappedOptional<ObjectiveC.EKEvent>, #unowned Swift.UnsafeMutablePointer<ObjectiveC.ObjCBool>) -> (#unowned ()) (WmBuildGroupsTask.swift)
19 EventKit 0x29ba72a7 __60-[EKEventStore enumerateEventsMatchingPredicate:usingBlock:]_block_invoke + 130
20 EventKit 0x29bad6af __41-[EKPredicateSearch startWithCompletion:]_block_invoke_2 + 690
21 libdispatch.dylib 0x36ed07bb _dispatch_call_block_and_release + 10
22 libdispatch.dylib 0x36ed9dab _dispatch_root_queue_drain + 866
23 libdispatch.dylib 0x36edacd7 _dispatch_worker_thread3 + 94
24 libsystem_pthread.dylib 0x37031e31 _pthread_wqthread + 668
line 9 a.e. WmBuildGroupsTask.swift:421 points to this row if event.attendees != nil{.
Can anybody spread the light on how to get rid of this crash or at least make code safety from crash?
[EDIT 1]
I tried also:
if event.hasAttendees {
if let attArray:NSArray = event.attendees{ // crashes here
/* ... */
}
}
Interesting that from command line: po event.hasAttendees returns true
when po event.attendees return null. But still crashes
[EDIT 2]
After upgrade to Swift 1.2 get the same crashes (In Crashlytics). Also tried:
if event.hasAttendees {
if let attArray:[EKParticipant] = event.attendees as? [EKParticipant] // crash here
{
/* ... */
}
}
The problematic event(s) refers to calendar like Google and as I pointed above 99.5% the same event works properly and I success to fetch attendees.
I'm not iOS Guru but looks like its internal iOS issue:
libobjc.A.dylib 0x36970d5f objc_exception_throw + 250
9 CoreFoundation 0x29096291 -[__NSSetM addObject:] + 608
10 EventKit 0x29b4eacf -[EKPersistentObject primitiveRelationValueForKey:] + 502
11 Foundation 0x29dc1617 -[NSObject(NSKeyValueCoding) valueForKey:] + 202
12 EventKit 0x29b5afc5 -[EKObjectToManyRelation _loadedItems] + 120
13 EventKit 0x29b5aef3 -[EKObjectToManyRelation _effectiveItems] + 102
14 EventKit 0x29b5ae69 -[EKObjectToManyRelation items] + 20
15 EventKit 0x29b5d179 -[EKCalendarItem attendees] + 36
Thanks,
It seems pretty clear that this is a bug in iOS and so you would need a hack to go around it until they fix it.
If it was Objective C I would've used a try catch block to try to catch the exception, so the app would not crash.
Here's an example of using a try block in Swift, by using an Objective C implementation:

Resources