在不引用 App functions/classes 的情况下解释崩溃日志

Interpreting a crash log without references to App functions/classes

我在上一个应用程序中遇到 "random" 崩溃(大约 2% 的用户似乎遇到过崩溃)但我无法从崩溃日志中找到任何有用的信息。似乎我没有对我的代码的任何参考,我发现非常难以理解发生了什么以及这个崩溃是如何产生的......我在这里粘贴崩溃日志的相关部分,关于它的任何提示或想法?有什么明显的我想念的吗...

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Triggered by Thread:  0

Last Exception Backtrace:
0   CoreFoundation                  0x18266d900 __exceptionPreprocess + 124 (NSException.m:162)
1   libobjc.A.dylib                 0x181cdbf80 objc_exception_throw + 56 (objc-exception.mm:531)
2   CoreFoundation                  0x18266d7d0 +[NSException raise:format:arguments:] + 108 (NSException.m:131)
3   Foundation                      0x182fe099c -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 112 (NSException.m:152)
4   UIKit                           0x187608ac0 -[UIApplication _runWithMainScene:transitionContext:completion:] + 3216 (UIApplication.m:3315)
5   UIKit                           0x1876055c0 -[UIApplication workspaceDidEndTransaction:] + 168 (UIApplication.m:2662)
6   FrontBoardServices              0x183c23790 -[FBSSerialQueue _performNext] + 184 (FBSSerialQueue.m:157)
7   FrontBoardServices              0x183c23b10 -[FBSSerialQueue _performNextFromRunLoopSource] + 56 (FBSSerialQueue.m:204)
8   CoreFoundation                  0x182624efc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 (CFRunLoop.c:1761)
9   CoreFoundation                  0x182624990 __CFRunLoopDoSources0 + 540 (CFRunLoop.c:1807)
10  CoreFoundation                  0x182622690 __CFRunLoopRun + 724 (CFRunLoop.c:2536)
11  CoreFoundation                  0x182551680 CFRunLoopRunSpecific + 384 (CFRunLoop.c:2814)
12  UIKit                           0x1873ce580 -[UIApplication _run] + 460 (UIApplication.m:2503)
13  UIKit                           0x1873c8d90 UIApplicationMain + 204 (UIApplication.m:3681)
14  KickLow                         0x100153604 0x100024000 + 1242628
15  libdyld.dylib                   0x1820f28b8 start + 4 (start_glue.s:80)

Thread 0 name:
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x0000000182210140 __pthread_kill + 8
1   libsystem_pthread.dylib         0x00000001822d8ef8 pthread_kill + 112 (pthread.c:1247)
2   libsystem_c.dylib               0x0000000182181dac abort + 140 (abort.c:91)
3   libc++abi.dylib                 0x0000000181cb53f4 abort_message + 132 (abort_message.cpp:47)
4   libc++abi.dylib                 0x0000000181cd1e98 default_terminate_handler() + 304 (cxa_default_handlers.cpp:67)
5   libobjc.A.dylib                 0x0000000181cdc248 _objc_terminate() + 124 (objc-exception.mm:678)
6   libc++abi.dylib                 0x0000000181ccef44 std::__terminate(void (*)()) + 16 (cxa_handlers.cpp:62)
7   libc++abi.dylib                 0x0000000181cceb10 __cxa_rethrow + 144 (cxa_exception.cpp:480)
8   libobjc.A.dylib                 0x0000000181cdc120 objc_exception_rethrow + 44 (objc-exception.mm:581)
9   CoreFoundation                  0x0000000182551728 CFRunLoopRunSpecific + 552 (CFRunLoop.c:2827)
10  UIKit                           0x00000001873ce580 -[UIApplication _run] + 460 (UIApplication.m:2503)
11  UIKit                           0x00000001873c8d90 UIApplicationMain + 204 (UIApplication.m:3681)
12  KickLow                         0x0000000100153604 0x100024000 + 1242628
13  libdyld.dylib                   0x00000001820f28b8 start + 4 (start_glue.s:80)

查看-[UIApplication _runWithMainScene:transitionContext:completion:]方法的反汇编,这是我们发现的:

0x111ef155d <+3038>: movq   0xd166b4(%rip), %rdi      ; (void *)0x0000000111ce4b10: NSAssertionHandler
0x111ef1564 <+3045>: movq   0xce0bcd(%rip), %rsi      ; "currentHandler"
0x111ef156b <+3052>: callq  *0xd64c5f(%rip)           ; (void *)0x0000000113e36800: objc_msgSend
0x111ef1571 <+3058>: movq   %rax, %rdi
0x111ef1574 <+3061>: callq  0x1129c0046               ; symbol stub for: objc_retainAutoreleasedReturnValue
0x111ef1579 <+3066>: movq   %rax, %r15
0x111ef157c <+3069>: leaq   0xda427d(%rip), %rax      ; @"Application windows are expected to have a root view controller at the end of application launch"
0x111ef1583 <+3076>: movq   %rax, (%rsp)
0x111ef1587 <+3080>: movl   [=10=]xd3c, %r9d              ; imm = 0xD3C 
0x111ef158d <+3086>: xorl   %eax, %eax
0x111ef158f <+3088>: movq   %r15, %rdi
0x111ef1592 <+3091>: movq   0xce0ba7(%rip), %rsi      ; "handleFailureInMethod:object:file:lineNumber:description:"

看来您的应用正在创建一个没有根视图控制器的 window。也许您的视图控制器无法创建。

移动我的评论作为答案。 @MatterGoal 很高兴知道它有所帮助。

您的问题似乎与 weird crash when launching app from Notification Center

相似

Either your code or a third-party library you are using is manually spinning the runloop. This is causing -workspaceDidEndTransaction: to be called re-entrantly and triggers a use after free. If you set a breakpoint on -[NSRunLoop runMode:beforeDate:] and -[NSRunLoop runUntilDate:], it should hit with the guilty code being on the previous stack frame.

While manually spinning the run loop is never recommended, if you can delay doing it until your application finishes starting up (all the launch app delegate calls received) you should avoid hitting this crash.