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

后端 未结 3 1953
忘了有多久
忘了有多久 2021-02-07 12:45

I\'m developing an iPhone application. I have an EXC_BAD_ACCESS that occurs only in the release target; when I build the debug target the exception does not occur.

3条回答
  •  我在风中等你
    2021-02-07 13:00

    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?

提交回复
热议问题