EXC_BAD_ACCESS中的code = 1和code = 2有什么区别? [英] what's the difference between code=1 and code=2 in EXC_BAD_ACCESS?

查看:381
本文介绍了EXC_BAD_ACCESS中的code = 1和code = 2有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到EXC_BAD_ACCESS错误的代码= 1或代码= 2.我想知道code = 1和code = 2有什么区别?

I am receiving code=1 or code=2 for EXC_BAD_ACCESS error. I am wondering what's the difference between code=1 and code=2?

推荐答案

代码= 1是KERN_INVALID_ADDRESS,代码= 2是KERN_PROTECTION_FAILURE.两者都是 技术说明TN2123 CrashReporter" 中的解释:

Code = 1 is KERN_INVALID_ADDRESS and code = 2 is KERN_PROTECTION_FAILURE. Both are explained in the "Technical Note TN2123 CrashReporter":

最常见的异常形式是:

The most common forms of exception are:

  • EXC_BAD_ACCESS/KERN_INVALID_ADDRESS —这是由线程引起的 访问未映射的内存.它可能是由数据访问触发的 或取指令;线程状态部分介绍了如何 分辨出差异.
  • EXC_BAD_ACCESS/KERN_PROTECTION_FAILURE —这是 由试图写入只读内存的线程引起的.这是 总是由数据访问引起的.
  • EXC_BAD_ACCESS/KERN_INVALID_ADDRESS — This is caused by the thread accessing unmapped memory. It may be triggered by either a data access or an instruction fetch; the Thread State section describes how to tell the difference.
  • EXC_BAD_ACCESS/KERN_PROTECTION_FAILURE — This is caused by the thread trying to write to read-only memory. This is always caused by a data access.

代码在 <mach/kern_return.h> :

#define KERN_INVALID_ADDRESS            1
                /* Specified address is not currently valid.
                 */

#define KERN_PROTECTION_FAILURE         2
                /* Specified memory is valid, but does not permit the
                 * required forms of access.
                 */

<mach/exception_types.h> 记录该代码 对于EXC_BAD_ACCESS是kern_return_t:

and in <mach/exception_types.h> it is documented that the code for a EXC_BAD_ACCESS is a kern_return_t:

#define EXC_BAD_ACCESS          1       /* Could not access memory */
                /* Code contains kern_return_t describing error. */
                /* Subcode contains bad memory address. */

这篇关于EXC_BAD_ACCESS中的code = 1和code = 2有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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