objective-c – 在EXC_BAD_ACCESS中代码= 1和代码= 2之间有什么区别?

栏目: Objective-C · 发布时间: 6年前

内容简介:我正在为EXC_BAD_ACCESS错误接收代码= 1或代码= 2.我想知道代码= 1和代码= 2之间有什么区别?http://stackoverflow.com/questions/19741409/whats-the-difference-between-code-1-and-code-2-in-exc-bad-access

我正在为EXC_BAD_ACCESS错误接收代码= 1或代码= 2.我想知道代码= 1和代码= 2之间有什么区别?

代码= 1是KERN_INVALID_ADDRESS,代码= 2是KERN_PROTECTION_FAILURE.两者都是

“Technical Note TN2123 CrashReporter”

年解释:

The most common forms of exception are:

  • 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:

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

http://stackoverflow.com/questions/19741409/whats-the-difference-between-code-1-and-code-2-in-exc-bad-access


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Design systems

Design systems

Not all design systems are equally effective. Some can generate coherent user experiences, others produce confusing patchwork designs. Some inspire teams to contribute to them, others are neglected. S......一起来看看 《Design systems》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换