了解崩溃日志 - KERN_PROTECTION_FAILURE

Posted

技术标签:

【中文标题】了解崩溃日志 - KERN_PROTECTION_FAILURE【英文标题】:understanding a crash log - KERN_PROTECTION_FAILURE 【发布时间】:2011-12-25 08:18:35 【问题描述】:

我正在尝试解决在我的应用程序使用过程中在不同时间点时不时发生不可预测的崩溃。 我非常感谢任何帮助,因为我对它可能是什么感到迷茫,我确实转换为 ARC 并在需要的地方使用了@AutoReleasePool,但我仍然不时得到这个......

日期/时间:2011-11-09 11:30:40.661 +0100 操作系统版本:iPhone OS 5.0 (9A334) 报告版本:104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_PROTECTION_FAILURE at 0x2fd74da8
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   CoreFoundation                  0x36e1e786 -[NSArray isEqualToArray:] + 14
1   CoreFoundation                  0x36e271cc -[NSArray isEqual:] + 64
2   CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
3   CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
4   CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
5   CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
6   CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
7   CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
8   CoreFoundation                  0x36e1e876 -[NSArray isEqualToArray:] + 254
9   CoreFoundation                  0x36e271cc -[NSArray isEqual:] + 64
10  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
11  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
12  CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
13  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
14  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
15  CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
16  CoreFoundation                  0x36e1e876 -[NSArray isEqualToArray:] + 254
17  CoreFoundation                  0x36e271cc -[NSArray isEqual:] + 64
18  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
19  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
20  CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
21  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
22  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
23  CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
24  CoreFoundation                  0x36e1e876 -[NSArray isEqualToArray:] + 254
25  CoreFoundation                  0x36e271cc -[NSArray isEqual:] + 64
26  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
27  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
28  CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
29  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
30  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
31  CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
32  CoreFoundation                  0x36e1e876 -[NSArray isEqualToArray:] + 254
33  CoreFoundation                  0x36e271cc -[NSArray isEqual:] + 64
34  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
35  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
36  CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
37  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
38  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
39  CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
40  CoreFoundation                  0x36e1e876 -[NSArray isEqualToArray:] + 254
41  CoreFoundation                  0x36e271cc -[NSArray isEqual:] + 64
42  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
43  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
44  CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
45  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
46  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
47  CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
48  CoreFoundation                  0x36e1e876 -[NSArray isEqualToArray:] + 254
49  CoreFoundation                  0x36e271cc -[NSArray isEqual:] + 64
50  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
51  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
52  CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
53  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
54  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
55  CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
56  CoreFoundation                  0x36e1e876 -[NSArray isEqualToArray:] + 254
57  CoreFoundation                  0x36e271cc -[NSArray isEqual:] + 64
58  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
59  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
60  CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
61  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
62  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
63  CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
64  CoreFoundation                  0x36e1e876 -[NSArray isEqualToArray:] + 254
65  CoreFoundation                  0x36e271cc -[NSArray isEqual:] + 64
66  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
67  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
68  CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
69  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
70  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
71  CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
72  CoreFoundation                  0x36e1e876 -[NSArray isEqualToArray:] + 254
73  CoreFoundation                  0x36e271cc -[NSArray isEqual:] + 64
74  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
75  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
76  CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
77  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
78  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
79  CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
80  CoreFoundation                  0x36e1e876 -[NSArray isEqualToArray:] + 254
81  CoreFoundation                  0x36e271cc -[NSArray isEqual:] + 64
82  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
83  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
84  CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
85  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
86  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
87  CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
88  CoreFoundation                  0x36e1e876 -[NSArray isEqualToArray:] + 254
89  CoreFoundation                  0x36e271cc -[NSArray isEqual:] + 64
90  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
91  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
92  CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
93  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
94  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
95  CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48
96  CoreFoundation                  0x36e1e876 -[NSArray isEqualToArray:] + 254
97  CoreFoundation                  0x36e271cc -[NSArray isEqual:] + 64
98  CoreFoundation                  0x36e1ef7e -[NSDictionary isEqualToDictionary:] + 310
99  CoreFoundation                  0x36e27d9c -[NSDictionary isEqual:] + 64
100 CoreFoundation                  0x36e27d40 -[__NSCFDictionary isEqual:] + 48

这个线程继续使用相同的语法大约 300 行...

【问题讨论】:

看起来像堆栈溢出 - 在您的应用程序中得到任何递归 - 任何嵌套在自身内部的数组或字典等。 【参考方案1】:

没有代码可以查看最好的猜测是一个方法正在递归地调用自己,直接或间接地并且没有到达终止。 NSDictionaryNSArray 中可能有一个条目引用回自身。

如果可能,请尝试在 Xcode 中暂停执行,以了解代码中发生这种情况的位置。

发布一些代码。

【讨论】:

我很乐意,但我的应用程序相当大 - 代码方面,你能告诉我代码的哪一部分是相关的吗? 尝试在 Xcode 中暂停以了解代码。在代码中放置 NSLog 和/或断点以定位问题区域。查找正在枚举或处理NSDictionaryNSArray 的区域。 +1 表示“可能在 NSDictionary 或 NSArray 中有一个条目引用回自身”。我确信这就是这里发生的事情。

以上是关于了解崩溃日志 - KERN_PROTECTION_FAILURE的主要内容,如果未能解决你的问题,请参考以下文章

如何调试此崩溃日志

试图了解tomcat hs_err_pid 日志

iOS应用崩溃日志分析

显示未发生的调用堆栈的崩溃日志

android开发之应用Crash自动抓取Log_自动保存崩溃日志到本地

使用静态库符号化应用程序的崩溃日志