开发者

Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000 Error

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes:开发者_如何学运维 KERN_PROTECTION_FAILURE at 0x00000000

What is Kernel protection error?

Where can i find the details about Exception type and code clearly?


You can see the full list of Mach kernel exceptions in /usr/include/mach/exception_types.h. Most if not all boil down to some flavor of “your program did something wrong”.

As hotpaw2 already told you, the specific thing you did wrong in this case was dereference NULL. You might have done this directly, in your own code, or indirectly by passing NULL to some library function or framework method. For example, passing NULL as one of the pointer arguments to memcpy is a good way to cause this crash.

Note that sending an Objective-C message to nil is OK—it does nothing and returns 0. On the other hand, passing nil as an argument in a message may not be OK. Passing nil where it isn't wanted may result in an NSException being thrown (which will cause a SIGTRAP, not SIGBUS, signal), or it may lead to some code eventually dereferencing NULL. Or it may be perfectly harmless. But you shouldn't do it unless the documentation explicitly says it's OK, because otherwise, even if it works now, it may break later.


The OS doesn't allow a user app to access (read or write) certain memory addresses. The address 0 (what a NULL or nil pointer points to) is one of those addresses. A very common cause of this is code using a pointer that's never been initialized.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜