I've been using Objective C on iOS for about a month but have a lot of prior C++ experience.
My understanding of EXC_BAD_ACCESS
is that it's essentially a Segmentation Fault, i.e. an attempt to access memory outside of allowed region. Though oddly enough I've also seen SIGSEGV
specifically somewhere in a crashing iOS app. I notice that there is a code parameter (e.g. code=1
) as part of this exception and I'm wondering what that code specifically means.
I've poked around google and can't seem to find formal documentation on this error, and apparently I'm not alone. Does anyone know what the code parameter here means?
If you look at the crash log that's generated on your device, you'll see:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at <some address>
For further description of the code
parameter associated with an exception, you can refer to usr/include/mach/kern_return.h
. It provides moderately-readable constant names along with short comment blurbs associated with the constant values.
The fastest way to open that file is to type the constant KERN_INVALID_ADDRESS
into your Xcode file and choose "Jump to Definition". ;)
FYI: code=1
relates directly to KERN_INVALID_ADDRESS
. The comment blurb associated with this constant reads:
/* Specified address is not currently valid. */