ios - 需要修复崩溃 : thunk for @escaping @callee_guaranteed () -> () + 28 (<compiler-generated>:0) 的错误

标签 ios multithreading logging crash

此错误表明 DispatchGroup 中的线程提前离开或未离开。希望一些资深的 iOS Swift 开发者可以对此提出想法

我处理这个问题的方法是检查每个 DispatchGroup 并检查是否可以缩小错误: - 这已经是几年的错误了 - 问题是堆栈跟踪没有找到崩溃发生的地方 我想错误在这里:

    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
```

最佳答案

如果不深入研究源代码,很难查明崩溃的确切原因,但上面的堆栈跟踪引用了 BuyTableViewController.swift:31。

我会使用 breakpoints查明原因,从 BuyTableViewController.swift 中的第 31 行开始作为崩溃的来源。

关于ios - 需要修复崩溃 : thunk for @escaping @callee_guaranteed () -> () + 28 (<compiler-generated>:0) 的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59722937/

相关文章:

c++ - 为什么在 iOS 中结构对齐不同

python - 线程似乎按顺序运行线程

c# - 如果我锁定一个对象而另一个线程使用该变量会怎样?

iis - 如何在 Azure 中启用 cs-host IIS 日志记录?

java - Tomcat 保存日志历史

java - log4j 写入控制台但不写入文件(Liferay + Tomcat)

ios - 更改应用商店应用名称

ios - 即使在检查内部存在值后,Swift NSDictionary 值也会返回 nil

iOS 错误解析 JSON

java - notify() 如何按顺序或随机唤醒线程