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

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

内容简介:我正在为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


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

查看所有标签

猜你喜欢:

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

ActionScript 3.0 Cookbook中文版

ActionScript 3.0 Cookbook中文版

Joey Lott、Adobe Dev Library / 陈建勋 / 电子工业 / 2007-11-01 / 78.00元

本书讨论了在Flash Player里执行的ActionScript3.0语言,采用问题—解法—讨论的形式讲解开发过程中常见问题的实际解法,例如:检测用户的 Flash Player 版本或操作系统;格式化日期和货币类型;接受用户输入及操作文字字符串;在运行时绘制各种形状;访问音频和视频;使用 Flash Remoting 进行远程过程调用;加载、发送和检索 XML 数据等。 全书涵盖客户端......一起来看看 《ActionScript 3.0 Cookbook中文版》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

在线进制转换器
在线进制转换器

各进制数互转换器

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具