问题描述
iPhone OS上 KERN_INVALID_ADDRESS
和 KERN_PROTECTION_FAILURE
之间的区别是什么?
What's the difference between KERN_INVALID_ADDRESS
and KERN_PROTECTION_FAILURE
on iPhone OS?
我有两个临时5分钟的特别测试版的崩溃报告,它们之间的主要区别(二进制图像:部分除外)就是这一部分:
I have two crash reports from an ad-hoc beta tester that are 5 minutes apart and the main difference between them (other than the "Binary Images:" section) is this section:
报告A:
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000008
报告B:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x67696c69
对于它的价值,两者都有这样的痕迹:
For what it's worth, both have this trace:
Thread 0 Crashed:
0 libobjc.A.dylib 0x30011940 objc_msgSend + 20
1 UIKit 0x30940174 -[UIWindow _shouldAutorotateToInterfaceOrientation:] + 60
2 UIKit 0x30a223d8 -[UIWindow _updateToInterfaceOrientation:duration:force:] + 36
3 UIKit 0x30958638 -[UIWindow _updateInterfaceOrientationFromDeviceOrientation] + 112
4 UIKit 0x30942514 -[UIWindow _handleDeviceOrientationChange:] + 72
5 Foundation 0x3054dc7a _nsnote_callback + 178
6 CoreFoundation 0x3024ea52 _CFXNotificationPostNotification + 298
7 Foundation 0x3054b854 -[NSNotificationCenter postNotificationName:object:userInfo:] + 64
8 UIKit 0x309414a4 -[UIDevice setOrientation:] + 124
9 UIKit 0x30938330 -[UIApplication handleEvent:withNewEvent:] + 5232
10 UIKit 0x30936ce8 -[UIApplication sendEvent:] + 60
11 UIKit 0x30936874 _UIApplicationHandleEvent + 4336
12 GraphicsServices 0x32046964 PurpleEventCallback + 1028
13 CoreFoundation 0x30254a70 CFRunLoopRunSpecific + 2296
14 CoreFoundation 0x30254164 CFRunLoopRunInMode + 44
15 GraphicsServices 0x3204529c GSEventRunModal + 188
16 UIKit 0x308f0374 -[UIApplication _run] + 552
17 UIKit 0x308eea8c UIApplicationMain + 960
18 MyApp 0x00015e24 0x1000 + 85540
19 MyApp 0x0000f138 0x1000 + 57656
另外,我没有在我的代码中的任何地方实现shouldAutorotateToInterfaceOrientation:方法。
Also, I do not implement the "shouldAutorotateToInterfaceOrientation:" method anywhere in my code.
推荐答案
EXC_BAD_ACCESS(SIGBUS)KERN_PROTECTION_FAILURE
表示虚拟地址明显错误:大多数CPU必须访问某个字节边界的内存。因为此处的数据访问是针对64位值(8)对齐的,所以它必须尝试执行获取128位值的指令(例如比较和交换指令 CMPXCHG16B
)。在任何情况下,您可以从这里的示例中看到它是 0x00000008
,这可能意味着您正在访问一个从开头偏移8个字节的结构元素,但是您的结构指针是 NULL
。
EXC_BAD_ACCESS (SIGBUS) KERN_PROTECTION_FAILURE
means that the virtual address is obviously wrong: most CPUs must access memory on a certain byte boundary. Because your data access here is aligned for a 64-bit value (8), it must be trying to execute an instruction that fetches a 128-bit value (such as compare and exchange instruction CMPXCHG16B
). In any case, you can see from the example here that it's 0x00000008
, which probably means you're accessing a structure element that's offset 8 bytes from the beginning, but your structure pointer is NULL
.
EXC_BAD_ACCESS(SIGSEGV)KERN_INVALID_ADDRESS
表示您正在参考的虚拟地址不在页面表中,或者您没有访问权限。这是一个您不允许访问的虚拟地址。对于您的示例地址 0x67696c69
,这可能不是指针被视为指针;或者包含指针的数据结构是免费的并被其他数据覆盖。
EXC_BAD_ACCESS (SIGSEGV) KERN_INVALID_ADDRESS
means that the virtual address you're refererencing is not in the page tables or you don't have access. It's a virtual address that you're not allowed to access. For your example address address 0x67696c69
it's likely that this is something that is not a pointer that was treated like a pointer; or your data structure that contains the pointer was free'd and overwritten with other data.
对于 KERN_INVALID_ADDRESS
示例,指针数据拼出ASCII'ilig'(因为它是小端)。因此,存储指针的内存可能会被某种字符串覆盖。
For your KERN_INVALID_ADDRESS
example, the pointer data spells out ASCII 'ilig' (because it's little endian). Therefore the memory where your pointer was stored was likely overwritten with some sort of string.
在这两种情况下,都可能会覆盖<$ c $中的数据结构。 c> UIWindow 。
In both cases, it's likely that something overwrote the data structures in your UIWindow
.
这篇关于KERN_INVALID_ADDRESS和KERN_PROTECTION_FAILURE之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!