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.
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?