Questions tagged [exc-bad-access]

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
2059 questions
8
votes
2 answers

EXC_BAD_ACCESS with sortUsingComparator

I understand what the error EXC_BAD_ACCESS means in general, but I'm puzzled about what's happening in my case. I have a custom class which has an NSComparator property sortWithThisComparator. If that property is set by the user, when I insert an…
sunny
  • 3,853
  • 5
  • 32
  • 62
8
votes
1 answer

How to diagnose a KERN_PROTECTION_FAILURE

I am getting an interesting crash that I can never seem to replicate on the simulator: Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: KERN_PROTECTION_FAILURE at 0x00000008 Crashed Thread: 0 Thread 0 Crashed: 0 libobjc.A.dylib …
Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556
8
votes
1 answer

iOS CoreLocation (null) crash

I've been getting this error in my app through Crashlytics. I can't find where and how this crash occurs. Here is the log from Crashlytics: Thread : Crashed: com.apple.main-thread 0 CoreLocation 0x0000000183f62304 (null) + 60044 1…
da32
  • 703
  • 1
  • 9
  • 18
8
votes
3 answers

swift setter causing exc_bad_access

I have a simple class below import Foundation public class UsefulClass: NSObject{ var test:NSNumber{ get{return self.test} set{ println(newValue) self.test = newValue } } override init()…
user3211122
  • 143
  • 1
  • 4
8
votes
3 answers

parser.parse() in Swift leads to EXC_BAD_ACCESS

I'm following this tutorial as a jump start for an RSS feeder app I'm working on in Swift. I know there are some things that have changed in Swift since this tutorial, but none of them seem to explain why I'm having this issue. Relevant Code (as far…
ShivKatall
  • 83
  • 5
8
votes
2 answers

va_list crash on 64-bits simulator

When using 64bits iOS simulator the init function below crashes with EXC_BAD_ACCESS (code=1) error. Would anyone know why ? And how to fix it properly. For information: 'format' is not nil, and it works just fine on 32bits simulator and any 32/64…
kokluch
  • 602
  • 5
  • 16
8
votes
2 answers

EXC_BAD_ACCESS on UIAlertview code=1

I am getting the EXC_BAD_ACCESS on [alert show] line. Why I am getting this? alert = [[UIAlertView alloc]initWithTitle:@"Application Alert" message:@"all date popup" delegate:self cancelButtonTitle:nil otherButtonTitles:@"Update",nil]; [alert…
swati sharma
  • 367
  • 4
  • 15
8
votes
3 answers

NSJSONSerialization results in EXC_BAD_ACCESS

Currently I am writing an app (Target iOS 6, ARC enabled) that uses JSON for data transmission and Core Data for persistent storage. The JSON data is generated out of a MySQL database by a PHP script via json_encode. My Problem is that with data…
7
votes
4 answers

iOS bad access impossible to find

I'm stuck with a stupid bad access since so many hours. I'm totally unable to find it. I hope some of you will be able to show me the answer into the light. In the code bellow it appear on the line : NSString * stringCallVisit = [[NSString…
Amnysia
  • 383
  • 1
  • 3
  • 12
7
votes
1 answer

EXC_BAD_ACCESS on objc_setAssociatedObject with -weak_library /usr/lib/libSystem.B.dylib linker flags

I have a EXC_BAD_ACCESS when I call objc_setAssociatedObject with the linker flags : -weak_library /usr/lib/libSystem.B.dylib linker flags. I absolutely need the linker flag because of this, do somebody know a workaround? (I also have a crash on…
gcamp
  • 14,622
  • 4
  • 54
  • 85
7
votes
2 answers

Attempting to create USE_BLOCK_IN_FRAME ... EXC_BAD_ACCESS with NSFetchedResultsController

This is an update to my problem. I am receiving this warning now when the program aborts. warning: Attempting to create USE_BLOCK_IN_FRAME variable with block that isn't in the frame. I can't find much information on what this means. This has me…
7
votes
2 answers

How to debug EXC_BAD_ACCESS in iPhone app when I can't determine the cause?

Help, I've been hacking at this for weeks now! I have this app I am developing in the Simulator, and I have done a lot of the UI stuff, it is just getting to the interesting part with data. It started immediately upon launch, about 90% of the time I…
Jay Imerman
  • 4,475
  • 6
  • 40
  • 55
7
votes
5 answers

UIWebView loading html5-Video EXC_BAD_ACCESS crash

in our iPad-App we are using an UIWebView to load different sites from one domain some of them with a hml5-Video. Sites without a Video do load perfectly. But when I'm loading a site containing htmlt5-video sometimes my app crashes during the…
7
votes
4 answers

EXC_BAD_ACCESS when using SQLite (FMDB) and threads on iOS 4.0

I am using FMDB to deal with my database which works fine. The app uses a background thread which is doing some work and needs to access the database. At the same time the main thread needs to run some queries on the same database. FMDB itself has a…
danielkbx
  • 125
  • 1
  • 5
7
votes
1 answer

Custom map view crashing in initWithCoder in swift

I have a UITableViewCell, which has a map view as subview. Created a Custom class which handles all the actions like adding annotations, delegates etc and named it as CustomeMap.swift. After I changed class name of map view to CustomeMap in Cell…
naresh
  • 627
  • 1
  • 7
  • 28