iOS Crash分析
2022-08-29 本文已影响0人
笑破天
SDK维护涉及2方面工作:1.排查crash是否是SDK引起 2.根据crash信息解决bug
。主要思路:先识别常见模式,然后再具体分析。
Crash 类型
singal全部类型可#import <sys/signal.h>点进去查看。常见类型见 Apple官方 或 译文
识别常见Crash模式
- Swift Runtime Error:
Exception Type: EXC_BREAKPOINT (SIGTRAP)
...
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
...
Thread 0 Crashed:
0 MyCoolApp 0x0000000100a71a88 @objc ViewController.viewDidLoad() (in MyCoolApp) (ViewController.swift:18)
- Language Exception
// 数组越界
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
...
Last Exception Backtrace:
0 CoreFoundation 0x19aae2a48 __exceptionPreprocess + 220
1 libobjc.A.dylib 0x19a809fa4 objc_exception_throw + 55
- Watchdog
// 主要是 0x8badf00d
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: Namespace SPRINGBOARD, Code 0x8badf00d
- Zombie objects
// 包含objc_msgSend或doesNotRecognizeSelector
Thread 0 Crashed:
0 libobjc.A.dylib 0x00000001a186d190 objc_msgSend + 16
1 Foundation 0x00000001a1f31238 __NSThreadPerformPerform + 232
2 CoreFoundation 0x00000001a1ac67e0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
Last Exception Backtrace:
0 CoreFoundation 0x1bf596a48 __exceptionPreprocess + 220
1 libobjc.A.dylib 0x1bf2bdfa4 objc_exception_throw + 55
2 CoreFoundation 0x1bf49a5a8 -[NSObject+ 193960 (NSObject) doesNotRecognizeSelector:] + 139
- Memory Access Issue
//类型EXC_BAD_ACCESS,并且有VM Region Info
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
VM Region Info: 0 is not in any region. Bytes before following region: 4307009536
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
__TEXT 0000000100b7c000-0000000100b84000 [ 32K] r-x/r-x SM=COW ...pp/MyGreatApp
- Framework Missing
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Description: DYLD, dependent dylib '@rpath/MyFramework.framework/MyFramework'
not found for '<path>/MyCoolApp.app/MyCoolApp', tried but didn't find:
'/usr/lib/swift/MyFramework.framework/MyFramework'
'<path>/MyCoolApp.app/Frameworks/MyFramework.framework/MyFramework'
'@rpath/MyFramework.framework/MyFramework'
'/System/Library/Frameworks/MyFramework.framework/MyFramework'
详细分析思路
https://developer.apple.com/documentation/xcode/analyzing-a-crash-report