EXC_BAD_ACCESS is a fatal error related to memory management on macOS and iOS.
This is a kind of crash that occurs when a program tries to access memory (including, but by no means limited to, Objective-C objects) that it has deallocated or had never allocated in the first place.
The correct name is EXC_BAD_ACCESS
, not EXEC
; the “EXC
” stands for “exception”, specifically a Mach kernel exception (meaning that the kernel did not like what your process did; this is not the same as a kernel panic). This isn't a C++ or Objective-C exception, so there's no catching it.
EXC_BAD_ACCESS
means that you've freed or released an object and then tried to use it later, or failed to retain an object that you planned to use again later.
To prevent this error from happening:
- Practice good memory management
- Run the static analyzer in Xcode to find bugs
- Run Instruments with the Zombies template to find premature-object-death bugs