异常代码:KERN_PROTECTION_FAILURE,0x00000000错误 [英] Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000 Error

查看:1109
本文介绍了异常代码:KERN_PROTECTION_FAILURE,0x00000000错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 异常类型:EXC_BAD_ACCESS(SIGBUS)
异常代码:KREN_PROTECTION_FAILURE at 0x00000000

什么是内核保护错误?

在哪里可以找到有关异常类型和代码的详细信息?

解决方案

您可以在/usr/include/mach/exception_types.h中查看Mach内核异常的完整列表。



由于hotpaw2已经告诉你,在这种情况下你做错了的具体事情是dereference NULL 。你可能在你自己的代码中直接做到这一点,或者通过将 NULL 传递给某些库函数或框架方法来间接做到这一点。例如,将 NULL 作为指向 memcpy 的指针参数之一是导致此崩溃的好方法。 p>

注意,发送一个Objective-C消息到 nil 是OK-它什么都不做, ,将 nil 作为消息中的参数传递可能不正确。传递 nil 在不想要的地方可能会导致NSException被抛出(这将导致 SIGTRAP ,而不是 SIGBUS ,signal),否则可能导致一些代码最终取消引用 NULL 。或者它可能是完全无害的。但是你不应该这样做,除非文档明确地说它是好的,否则,即使它现在工作,它可能会破坏。


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.

这篇关于异常代码:KERN_PROTECTION_FAILURE,0x00000000错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆