如何调试EXC_BAD_ACCESS错误 [英] How to debug EXC_BAD_ACCESS bug

查看:222
本文介绍了如何调试EXC_BAD_ACCESS错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到一个错误

EXC_BAD_ACCESS代码= 2 at0xb0987654

EXC_BAD_ACCESS code=2 at0xb0987654

我想知道如何在0xb0987654上打印出该值?

I am wondering how to print out the value at 0xb0987654?

推荐答案

要调试EXC_BAD_ACCESS,通常可以通过启用僵尸对象来找出悬空指针的位置.

To debug an EXC_BAD_ACCESS, you can generally find out the where the dangling pointer is by enabling zombie objects.

Xcode

选择编辑方案,然后在运行"部分中选择诊断"选项卡,然后单击僵尸对象"选项.

Choose edit scheme, then Diagnostics tab in the Run section, then click the 'Zombie Objects' option.

AppCode

选择编辑目标,并添加以下环境变量:

Choose edit target, and add the following environment variable:

NSZombieEnabled=YES

EXC_BAD_ACCESS的另一个原因可能是无限递归,可以通过添加一些日志记录来找到它.

Another cause for EXC_BAD_ACCESS can be infinite recursion, which can be found by adding some logging.

C ++更新:

要使用Clang编译器调试C ++中的悬空指针,请尝试使用地址清理器(ASAN)来自Google.

To debug dangling pointers in C++ with the Clang compiler try using Address Sanitizer (ASAN) from Google.

这篇关于如何调试EXC_BAD_ACCESS错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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