How to debug EXC_BAD_ACCESS that occurs only on release target for an iPhone app?

丶灬走出姿态 提交于 2019-12-03 05:32:19

In objc_msgSend, r0 contains a pointer to the receiver of the message. Your app is crashing when it tries to load something pointed to by the receiver. The most likely explanation is that you are either messaging an object that hasn't been initialized, or an object that has already been freed, but there are other possibilities.

You also may want to have a look at "So you crashed in objc_msgSend"; it's written about the Intel OS X platform, but much of it also applies to the iPhone OS.

When u enable NSZombieEnabled you should check the console as it will probably tell u which line you're getting the EXC_BAD_ACCESS. From there you would be able to fix it. Don't forget to disable it for final release.

Based on your gdb session, it seems possible that you're over-releasing some object, although I agree that the 0x3100000 seems improbable. Have you tried running Build and Analyze? Static analysis can catch many common over-release bugs.

Based on that memory address, a buffer overrun seems more likely. This could also explain why it only crashes in release mode when you're compiling with -O2 or greater. The optimizations may be laying out your memory in such a way that your buffer overrun happens to cause a crash in release mode but not in debug mode.

Are you doing anything funky with old school C void * pointers? Working with any null terminated C strings? Doing any pointer arithmetic?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!