Ale*_*iks 6 iphone nsnumber crash-log sigabrt
我收到了客户的崩溃日志,以了解我的应用程序崩溃iPhone的原因.
这里来自崩溃日志的一些信息:
Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x00000000, 0x00000000 Crashed Thread: 0
线程0的堆栈跟踪
Thread 0 Crashed: 0 libSystem.B.dylib 0x3293f98c 0x328c1000 + 518540 1 libSystem.B.dylib 0x3293f97c 0x328c1000 + 518524 2 libSystem.B.dylib 0x3293f96e 0x328c1000 + 518510 3 libSystem.B.dylib 0x3295461a 0x328c1000 + 603674 4 libstdc++.6.dylib 0x30a143b0 0x309cf000 + 283568 5 libobjc.A.dylib 0x3347a858 0x33475000 + 22616 6 libstdc++.6.dylib 0x30a12776 0x309cf000 + 276342 7 libstdc++.6.dylib 0x30a127ca 0x309cf000 + 276426 8 libstdc++.6.dylib 0x30a12896 0x309cf000 + 276630 9 libobjc.A.dylib 0x33479714 0x33475000 + 18196 10 CoreFoundation 0x335c8210 0x33534000 + 606736 11 CoreFoundation 0x3354ea8e 0x33534000 + 109198 12 CoreFoundation 0x33545ab8 0x33534000 + 72376 13 Journaler Lite 0x0001699e -[AccountManager unsignedIntegerValueForPath:] (AccountManager.m:151) ...
这是来自的代码AccountManager.m:
NSNumber *number = ...;
if (number) {
return [number unsignedIntegerValue]; // line 151
} else {
return 0;
}
主要问题是如何阅读此类崩溃日志?该应用程序崩溃在系统库内的某个地方,没有更多的额外信息.如何找到崩溃的原因?
更新:
我搜索过很多论坛帖子,其中异常类型是EXC_CRASH (SIGABRT)来自崩溃线程堆栈的第一行:
Thread 0 Crashed: 0 libSystem.B.dylib 0x3293f98c 0x328c1000 + 518540 1 libSystem.B.dylib 0x3293f97c 0x328c1000 + 518524 2 libSystem.B.dylib 0x3293f96e 0x328c1000 + 518510 3 libSystem.B.dylib 0x3295461a 0x328c1000 + 603674 4 libstdc++.6.dylib 0x30a143b0 0x309cf000 + 283568 5 libobjc.A.dylib 0x3347a858 0x33475000 + 22616 6 libstdc++.6.dylib 0x30a12776 0x309cf000 + 276342 7 libstdc++.6.dylib 0x30a127ca 0x309cf000 + 276426 8 libstdc++.6.dylib 0x30a12896 0x309cf000 + 276630 9 libobjc.A.dylib 0x33479714 0x33475000 + 18196 10 CoreFoundation 0x335c8210 0x33534000 + 606736 11 CoreFoundation 0x3354ea8e 0x33534000 + 109198
这个异常类型(EXC_CRASH (SIGABRT))是什么意思?
首先,您需要使用DSYM来表示崩溃日志,以了解发生了什么.从构建应用程序时起,您需要拥有DSYM文件.DSYM文件允许您将映射从这些内存地址反向回可读行代码.
SIGABRT是当您有未处理的异常时获得的信号,例如调用[someArray objectAtIndex:2]数组只有1个项目.或者,更常见的是,一个无法识别的选择器:[NSArray unsignedIntValue].
在这个问题中查看此崩溃日志.请注意,Foundation中的调用堆栈库与您的代码相同 - 而且它是一个无法识别的选择器.
你的代码是:
NSNumber *num = foo;
if (num)
{
bar = [num unsignedIntValue];
}
Run Code Online (Sandbox Code Playgroud)
你没有告诉我们 - 但非常重要 - 是什么在"foo".你如何分配NSNumber?如果它是除NSNumber之外的任何其他对象,那么您的崩溃日志将与您的一样.
如果你想在编程中真正防守,你可以说:
if (num && [num isKindOfClass:[NSNumber class]])
Run Code Online (Sandbox Code Playgroud)
但实际上,无论你的"foo"是什么,都应该总是返回一个NSNumber.
| 归档时间: |
|
| 查看次数: |
14619 次 |
| 最近记录: |