我遇到了一次看门狗的终止事故。在观看了这 WWDC会话并阅读了有关看门狗崩溃的相关文档之后,我怀疑存在某种类型的死锁。
但我无法理解我的代码是如何导致死锁的。由于字符限制,我在这里删除了一些线程的堆栈跟踪。完整的崩溃日志可以在此GitHub要点中找到。
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
您能识别哪些线程可能导致死锁吗?也许还有别的问题?
这就是它在XCode中崩溃管理器中的样子。
如能在这方面提供任何帮助,将不胜感激。
谢谢
发布于 2022-05-09 19:16:38
显然,Thread 0
崩溃是因为它无法访问第5行中的NSManagedObjectContext
使用performBlockAndWait
时使用的队列。显然,在performBlockAndWait
(10,19,45…)其他行的同一线程中也使用了相同的队列。。这是没有问题的,因为可以重新调用performBlockAndWait
,请参阅文档。
但是,它显然也被其他带有performBlockAndWait
的线程使用(Thread 9
,第15行;Thread 11
,第5行)。在我看来,其中一个线程分配了一些Thread 0
完成其工作所需的公共资源--死锁。
我不可能找到这个关键的资源是什么。死锁往往很难找到。
一个可能破坏您的代码的小建议是用一个performBlockAndWait
替换一个performBlock
,看看受影响的线程是否继续运行,即使代码被破坏了。也许这会给你一些提示去哪里找这个问题。
发布于 2022-05-08 00:04:57
从通知异步调用闭包解决了这个问题。您可以查看内存图来理解这一点。
https://stackoverflow.com/questions/72010502
复制相似问题