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
0
votes
0 answers

EXC_BAD_ACCESS on NSURLSession on Simulator

I am pretty new to objective C. Started working with callbacks using NSURLSession. The application runs perfect on device.But the simulator gives some errors. I am trying to do a POST and have a delegate which informs the caller when the response is…
0
votes
0 answers

exc_bad_access only iOS Version < 9 - textfield deallocated (

My app doesn't work for Versions older than iOS 9.x The APP throws an EXC_BAD_ACCESS exception at a textField. The textField is in a tableView. I enabled Zombie Objects: "[_UILabelLayer opacity]: message sent to deallocated instance 0x81018770" It…
kuzdu
  • 7,124
  • 1
  • 51
  • 69
0
votes
1 answer

swift - HomeKit updateTargetValue of HMCharacteristicWriteAction crashes

I am trying to update target value of an action (HMCharacteristicWriteAction) but it always crashes with EXC_BAD_ACCESS (code=1, address=0x50). My code snippet: print("\(action) --> \(action.dynamicType)") //
quanguyen
  • 1,443
  • 3
  • 17
  • 29
0
votes
0 answers

Error calling on managedobject with EXC_BAD_ACCESS

I searched a lot for this error and was not able to find a solution. I have my managedObject: lazy var managedObjectContext: NSManagedObjectContext = { let coordinator = self.persistentStoreCoordinator var managedObjectContext =…
Vannian
  • 1,490
  • 5
  • 14
  • 26
0
votes
1 answer

Segmentation Fault: 11 when allocating a matrix

I get segmentation fault when using an allocated matrix and I don't understand why. This code currently works and doesn't work dependently from the computer #include void allocMatrix(int ***M, int n, int m) { *M = (int**)malloc(n *…
BlackBox
  • 631
  • 1
  • 5
  • 19
0
votes
2 answers

Splash Screen: EXC_BAD_ACCESS after calling dismissModalViewControllerAnimated delayed

I am trying to create a 1-2 second splashcreen for my application using a modal view controller however when i try to dismiss the view my application crashes with a bad access error. So in my application delegate i have: - (BOOL)…
katbyte
  • 2,665
  • 2
  • 28
  • 19
0
votes
1 answer

Getting EXEC_BAD_ACCES after leaving IBAction

Im trying to fetch information from a SQLlite database with Core Data and just after leaveing the IBAction that get the NSManageObject from DB the App crash with only a EXEC_BAD_ACCESS error. The code executed is: -…
0
votes
1 answer

Release of NSString Causing EXC_BAD_ACCESS

Thanks for your help on this one. I am pulling a NSDictionary from a plist in my main bundle and am having troubles. Here is the code: - (void)viewDidLoad { // Pull in FAQ from Plist NSString *strFAQPlist = [[NSBundle mainBundle]…
Jesse Bunch
  • 6,651
  • 4
  • 36
  • 59
0
votes
2 answers

EXC_BAD_ACCESS in for loop

In this code, in the second for loop, i get an EXC_BAD_ACCESS if I use an identifier other than i and j. if (UIDeviceOrientationIsPortrait(deviceOrientation)){ numRows = 4; numCols = 3; }else { numRows = 6; numCols = 1; } for (int…
joec
  • 3,533
  • 10
  • 60
  • 89
0
votes
2 answers

Swift TextField Method Not Called, Delegate is Set, now BAD_ACCESS Errors

there are many similar questions about TextFields delegate method textfieldshouldreturn not being called, but all were solved by setting the delegate. Ive set the delegate, and also have a perfectly fine example in another project I've copied almost…
R.P. Carson
  • 439
  • 5
  • 20
0
votes
3 answers

Pointer to pointer gets EXC_BAD_ACCESS when calling function

I have two classes, one called Handler and one called Dice. In my Handler class i have a private variable called Dice **dices and a public function called rollDices. And in my Dice class i have a function called toss that will randomize a number…
pottsork
  • 33
  • 6
0
votes
1 answer

Blocks for Passing Data between VC's - EXC_BAD_ACCESS

I'm using blocks to pass data from a view controller, VC3, which appears within a modal view that is pushed by VC1. The modal displayed is VC2, and it shows VC3 before being dismissed. I am getting a EXC_BAD_ACCESS error when using the blocks. Below…
emleeh
  • 106
  • 1
  • 5
0
votes
1 answer

I am having BAD_ACCESS error - Is my memory allocation understand correct

So here is what I am trying to do @implementation someHelper +(BOOL) GetInfo:(NSData **)info1, (NSString**) info2 { __block _Bool out = NO; //do stuff to get input [[Bool result] startSession:input callsBack:^(Abc obj, Bool status) …
0
votes
1 answer

Creating and assigning a new NSManagedObject to a new NSManagedObject *sometimes* fails

I am creating a new NSManagedObject called "translation". Within the translation I need to create two additional NSManagedObjects called "phrase". Sometimes one of the phrase assignments will throw an error, but when I inspect the values they all…
Sean
  • 2,412
  • 3
  • 25
  • 31
0
votes
1 answer

EXC_BAD_ACCESS when saving parentContext

Alright, I have a piece of code that queries everything from an entity in CoreData, cycles through them all, processes the data, appends it to an array then deletes the CoreData object. Saving the current context works just fine, but calling save on…
Simon Germain
  • 6,834
  • 1
  • 27
  • 42