This bug suggested a thread in a DispatchGroup is leaving early or not leaving. Hoping some senior iOS Swift devs can give thoughts on this
My way to take care of this is to review each DispatchGroup and check to see if the error can be narrowed: - This has been a bug for a few years - the problem is the stack trace does not locate where the crash is happening I suppose the error is here:
Legacy Code:
let group = DispatchGroup()
group.enter()
DispatchQueue.walletQueue.async {
if self.walletManager.signTransaction(tx, pin: pin) {
self.publish(completion: completion)
success = true
}
group.leave()
}
let result = group.wait(timeout: .now() + 30.0)
if result == .timedOut {
...
vs.
Proposed Code:
let group = DispatchGroup()
group.enter()
DispatchQueue.walletQueue.async {
if self.walletManager.signTransaction(tx, pin: pin) {
self.publish(completion: completion)
success = true
group.leave()
} else {
didSignTransaction = false
group.leave()
}
}
let result = group.wait(timeout: .now() + 30.0)
if result == .timedOut {
...
```
Date/Time: 2020-01-11 14:25:01.5722 +0100
Launch Time: 2020-01-11 14:12:54.0779 +0100
OS Version: iPhone OS 13.3 (17C54)
Release Type: User
Baseband Version: 5.30.01
Report Version: 104
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001949ae500
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [2913]
Triggered by Thread: 0
Thread 0 name:
Thread 0 Crashed:
0 libdispatch.dylib 0x00000001949ae500 dispatch_group_leave$VARIANT$armv81.cold.1 + 36
1 libdispatch.dylib 0x00000001949796a8 dispatch_group_leave$VARIANT$armv81 + 112 (semaphore.c:303)
2 Litewallet 0x0000000104a72e3c thunk for @escaping @callee_guaranteed () -> () + 28 (<compiler-generated>:0)
3 libdispatch.dylib 0x00000001949a6610 _dispatch_call_block_and_release + 24 (init.c:1408)
4 libdispatch.dylib 0x00000001949a7184 _dispatch_client_callout + 16 (object.m:495)
5 libdispatch.dylib 0x000000019498a34c _dispatch_main_queue_callback_4CF$VARIANT$armv81 + 996 (inline_internal.h:2484)
6 CoreFoundation 0x0000000194c585e4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 (CFRunLoop.c:1749)
7 CoreFoundation 0x0000000194c535d8 __CFRunLoopRun + 2004 (CFRunLoop.c:3069)
8 CoreFoundation 0x0000000194c52adc CFRunLoopRunSpecific + 464 (CFRunLoop.c:3192)
9 GraphicsServices 0x000000019ebd8328 GSEventRunModal + 104 (GSEvent.c:2246)
10 UIKitCore 0x0000000198d4dae0 UIApplicationMain + 1936 (UIApplication.m:4773)
11 Litewallet 0x0000000104a5e308 main + 68 (BuyTableViewController.swift:31)
12 libdyld.dylib 0x0000000194adc360 start + 4
Thread 1 name:
Thread 1:
0 libsystem_kernel.dylib 0x0000000194ab0634 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x0000000194aafaa0 mach_msg + 72 (mach_msg.c:103)
2 CoreFoundation 0x0000000194c58288 __CFRunLoopServiceMachPort + 216 (CFRunLoop.c:2575)
3 CoreFoundation 0x0000000194c533a8 __CFRunLoopRun + 1444 (CFRunLoop.c:2931)
4 CoreFoundation 0x0000000194c52adc CFRunLoopRunSpecific + 464 (CFRunLoop.c:3192)
5 Foundation 0x0000000194f927f4 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 228 (NSRunLoop.m:374)
6 Foundation 0x0000000194f926d4 -[NSRunLoop(NSRunLoop) runUntilDate:] + 88 (NSRunLoop.m:421)
7 UIKitCore 0x0000000198de6204 -[UIEventFetcher threadMain] + 152 (UIEventFetcher.m:637)
8 Foundation 0x00000001950c30a4 __NSThread__start__ + 848 (NSThread.m:724)
9 libsystem_pthread.dylib 0x00000001949f5d8c _pthread_start + 156 (pthread.c:896)
10 libsystem_pthread.dylib 0x00000001949f976c thread_start + 8
Thread 2:
0 libsystem_pthread.dylib 0x00000001949f9758 start_wqthread + 0
Thread 3:
0 libsystem_pthread.dylib 0x00000001949f9758 start_wqthread + 0
Thread 4:
0 libsystem_pthread.dylib 0x00000001949f9758 start_wqthread + 0
Thread 5:
0 libsystem_pthread.dylib 0x00000001949f9758 start_wqthread + 0
Thread 6 name:
Thread 6:
0 libsystem_kernel.dylib 0x0000000194ab0634 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x0000000194aafaa0 mach_msg + 72 (mach_msg.c:103)
2 CoreFoundation 0x0000000194c58288 __CFRunLoopServiceMachPort + 216 (CFRunLoop.c:2575)
3 CoreFoundation 0x0000000194c533a8 __CFRunLoopRun + 1444 (CFRunLoop.c:2931)
4 CoreFoundation 0x0000000194c52adc CFRunLoopRunSpecific + 464 (CFRunLoop.c:3192)
5 CFNetwork 0x0000000197f094e8 -[__CoreSchedulingSetRunnable runForever] + 192 (CoreSchedulingSet.mm:1372)
6 Foundation 0x00000001950c30a4 __NSThread__start__ + 848 (NSThread.m:724)
7 libsystem_pthread.dylib 0x00000001949f5d8c _pthread_start + 156 (pthread.c:896)
8 libsystem_pthread.dylib 0x00000001949f976c thread_start + 8
Thread 7:
0 libsystem_pthread.dylib 0x00000001949f9758 start_wqthread + 0
Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x0000000000000000 x1: 0x0000000000000002 x2: 0x0000000000000002 x3: 0x00000001949c26e8
x4: 0x0000001400000002 x5: 0x0000001600000002 x6: 0x0000000000000003 x7: 0x0000000000000680
x8: 0x0000000000000000 x9: 0x0000000000000004 x10: 0x0000000000000000 x11: 0x0000000200000002
x12: 0x0000000000000100 x13: 0x0000000093a0792e x14: 0x0000000093c08000 x15: 0x0000000000000010
x16: 0x0000000194979638 x17: 0x0000000013c00000 x18: 0x0000000000000000 x19: 0x0000000104ac651c
x20: 0x0000000281b70140 x21: 0x0000000280e8f740 x22: 0x0000000280e803c0 x23: 0x0000000000000000
x24: 0x0000000002ffffff x25: 0x0000000280e80600 x26: 0x00000001050718e0 x27: 0x00000000000020ff
x28: 0x0000000000000114 fp: 0x000000016b3a6ac0 lr: 0x00000001949796a8
sp: 0x000000016b3a6ac0 pc: 0x00000001949ae500 cpsr: 0x00000000
esr: 0xf2000001 Address size fault
```
Hard to pinpoint the exact cause of the crash without looking deeper into the source, but the above stack trace is referencing BuyTableViewController.swift:31.
I would use breakpoints to pinpoint the cause, starting with line 31 in BuyTableViewController.swift as the source of the crash.
User contributions licensed under CC BY-SA 3.0