Hi,
I encountered a crash that happens randomly on certain macOS. Here's the crash log. For clarity, only the crashed queue's stack trace is added.
Process: Engage [6891]
Path: /Applications/Engage.app/Contents/MacOS/Engage
Identifier: com.mycompany.engage
Version: 2.0.1 (20111120)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Engage [6891]
User ID: 2123560928
Date/Time: 2021-11-17 16:36:20.753 +0800
OS Version: Mac OS X 10.14.6 (18G9323)
Report Version: 12
Anonymous UUID: C642EE95-AF30-723E-91B8-A1C9D4ECD9A6
Sleep/Wake UUID: B95DB75A-69E8-4F19-B735-CEC7A698AE00
Time Awake Since Boot: 40000 seconds
Time Since Wake: 910 seconds
System Integrity Protection: enabled
Crashed Thread: 5 Dispatch queue: Contacts fetching queue
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Illegal instruction: 4
Termination Reason: Namespace SIGNAL, Code 0x4
Terminating Process: exc handler [6891]
Application Specific Information:
API MISUSE: Resurrection of an object
Thread 0:: Dispatch queue: com.apple.main-thread
...
Thread 1:
...
Thread 2:
...
Thread 3:
...
Thread 4:: Dispatch queue: com.apple.root.background-qos
...
Thread 5 Crashed:: Dispatch queue: Contacts fetching queue
0 libdispatch.dylib 0x00007fff703929a6 _os_object_retain + 34
1 com.apple.AppKit 0x00007fff41bbc6da -[_NSWorkspaceFileOperation initWithQueue:URLs:operation:completionHandler:] + 111
2 com.apple.AppKit 0x00007fff41bbc5a0 -[NSWorkspace recycleURLs:completionHandler:] + 726
3 com.apple.AddressBook.core 0x00007fff53cd5004 -[ABPersistentStoreBuilder removeDotNewPathForDatabasePath] + 212
4 com.apple.AddressBook.core 0x00007fff53cd42f3 -[ABPersistentStoreBuilder addPersistentStoreAtDatabasePath:] + 61
5 com.apple.AddressBook.core 0x00007fff53cd3da4 -[ABPersistentStoreCoordinatorFactory addStoresForAccounts:withStoreBuilder:] + 333
6 com.apple.AddressBook.core 0x00007fff53cccd7f -[ABPersistentStoreCoordinatorFactory pool_makeCoordinatorForAllAvailableSources] + 114
7 com.apple.AddressBook.core 0x00007fff53ccccc1 ABResultWithAutoreleasePool + 59
8 com.apple.AddressBook.core 0x00007fff53cccc80 -[ABPersistentStoreCoordinatorFactory makeCoordinatorForAllAvailableSources] + 65
9 com.apple.AddressBook.core 0x00007fff53ccca4c -[ABPersistentStoreCoordinatorMap nts_coordinatorForAllSourcesAndDidUpdateMap:] + 114
10 com.apple.AddressBook.core 0x00007fff53ccc99d -[ABPersistentStoreCoordinatorCache coordinatorForAllSources] + 55
11 com.apple.AddressBook.core 0x00007fff53ccc777 -[ABAddressBook(ABAddressBook_CoreData_Private) nts_managedObjectContextWithStoreDescription:databasePath:loadFailure:] + 288
12 com.apple.AddressBook.core 0x00007fff53ccc377 -[ABAddressBook(ABAddressBook_CoreData_Private) managedObjectContext] + 109
13 com.apple.AddressBook.core 0x00007fff53ccc2c0 __38+[ABAddressBook nts_SharedAddressBook]_block_invoke + 24
14 com.apple.AddressBook.core 0x00007fff53ccc257 ABRunWithLock + 32
15 com.apple.AddressBook.core 0x00007fff53cc8873 +[ABAddressBook nts_SharedAddressBook] + 137
16 com.apple.AddressBook.core 0x00007fff53cc8747 +[ABAddressBook nts_CreateSharedAddressBook] + 47
17 com.apple.AddressBook.core 0x00007fff53cc817e +[ABAddressBook sharedAddressBook] + 81
18 com.apple.contacts.ContactsPersistence 0x00007fff572427ee -[CNCDPersistenceStack makePersistenceContext] + 27
19 com.apple.contacts 0x00007fff43d048dd __71+[CNCDContactFetcher contactsForFetchRequest:inPersistenceStack:error:]_block_invoke + 73
20 com.apple.AddressBook.ContactsFoundation 0x00007fff571e407a +[CNEither eitherWithBlock:] + 63
21 com.apple.contacts 0x00007fff43d047e1 +[CNCDContactFetcher contactsForFetchRequest:inPersistenceStack:error:] + 147
22 com.apple.contacts 0x00007fff43d0462a -[CNCoreDataMapperX contactObservableForFetchRequest:] + 137
23 com.apple.contacts 0x00007fff43d03fc3 __91-[CNDataMapperContactStore enumerateContactsAndMatchInfoWithFetchRequest:error:usingBlock:]_block_invoke + 172
24 libsystem_trace.dylib 0x00007fff705f6724 os_activity_apply_f + 66
25 com.apple.contacts 0x00007fff43d03ed8 -[_CNContactsLogger fetchingContacts:] + 225
26 com.apple.contacts 0x00007fff43d03cee -[CNDataMapperContactStore enumerateContactsAndMatchInfoWithFetchRequest:error:usingBlock:] + 304
27 com.apple.contacts 0x00007fff43d16d6e -[CNContactStore enumerateContactsWithFetchRequest:error:usingBlock:] + 149
28 com.mycompany.engage 0x00000001076181f4 0x1074c6000 + 1384948
29 com.mycompany.engage 0x00000001076548ce 0x1074c6000 + 1632462
30 libdispatch.dylib 0x00007fff703925f8 _dispatch_call_block_and_release + 12
31 libdispatch.dylib 0x00007fff7039363d _dispatch_client_callout + 8
32 libdispatch.dylib 0x00007fff703998e0 _dispatch_lane_serial_drain + 602
33 libdispatch.dylib 0x00007fff7039a396 _dispatch_lane_invoke + 385
34 libdispatch.dylib 0x00007fff703a26ed _dispatch_workloop_worker_thread + 598
35 libsystem_pthread.dylib 0x00007fff705d3611 _pthread_wqthread + 421
36 libsystem_pthread.dylib 0x00007fff705d33fd start_wqthread + 13
Thread 6:
...
In the stack trace, two lines that are related to my app
28 com.mycompany.engage 0x00000001076181f4 0x1074c6000 + 1384948
29 com.mycompany.engage 0x00000001076548ce 0x1074c6000 + 1632462
It just call the enumerateContacts(with: fetchRequest) on the instance of CNContactStore, and the fetchRequest is created using CNContactFetchRequest(keysToFetch: keysToFetch). Pretty straightforward.
The stack trace goes into he Contacts framework, and then goes into the AddressBook framework, and eventually crashed. What could be the possible cause of the crash?
Selecting any option will automatically load the page