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
1 answer

MKMapView causes EXC_BAD_ACCESS when testing only

when testing on device only, i am getting EXC_BAD_ACCESS. This does not happen when i just run the app. I am concerned my users will experience the crash even though i am not when not testing. Anyone have any ideas why? It does not seem related to…
mreynol
  • 309
  • 3
  • 17
0
votes
0 answers

exc_bad_access on touch UITextField

I'm developing an application with XCode 7.01 and Objective C. In storyboard there is a Login screen with 2 UITextField: user and password. When execute in simulator since iPhone 5S works fine, but when i execute in iPhone 6 device and iPhone 6/6+…
0
votes
1 answer

When an object is being instantiated, how can a BAD ACCESS occur when sending a NSKeyValueNotifyObserver message to a deallocated object

We have had this weird issue. When we instantiated an object, we also instantiate a property that belongs to that object: -(instancetype)init { self = [super init]; if (self) { [self setDocument]; } return…
A O
  • 5,516
  • 3
  • 33
  • 68
0
votes
0 answers

EXC_BAD_ACCESS error on mac

I'm trying to run my code on a Mac computer. It always works fine on Windows (I'm using Microsoft Visual Studio), but when I run it on a in XCode, the following code sometimes crashes with an EXC_BAD_ACCESS error. board_t* board_initBoard() { …
nschneid
  • 1
  • 1
0
votes
3 answers

NSNumber intValue giving EXC_BAD_ACCESS

I have an NSNumber being passed to be via a 3rd party API, and when I call intValue on the index I get a EXC_BAD_ACCESS error: -(CPFill *) barFillForBarPlot:(CPBarPlot *)barPlot recordIndex:(NSNumber *)index; { NSLog(@"bar index %i", index); …
Mark
  • 14,820
  • 17
  • 99
  • 159
0
votes
1 answer

Calling NSManagedObject function breaks but not when accessing a variable

So I have an NSManagedObject called Student. There is a part of my code that sometimes breaks when I call a method on a Student object e.g student.performTask(). This gives me a EXC_BAD_ACESS which makes me believe it is a threading core data issue.…
boidkan
  • 4,691
  • 5
  • 29
  • 43
0
votes
0 answers

EXC_BAD_ACCESS on resume on iOS device with Intel XDK

I'm making a iOS game using the Intel XDK, but when the game is suspended and resume , it crashed with an EXC_BAD_ACCESS error (on iphone5,iOS 8.4.1). I saw here : http://www.christian-cook.co.uk/ how to debug and fix it, but I don't know how to do…
0
votes
1 answer

Fill Table View with JSON

Here goes a newbie question: Create a new project in Xcode: File > New Project and select Navigation-based Application from iPhone OS templates. Install json-framework as explained here. Edit RootViewController.h's interface section into…
Ali
  • 1,396
  • 14
  • 37
0
votes
1 answer

Unable to set class properties

Now Im sure Im doing something extremely schoolboy here, but Im seriously hitting my head against a wall, for some reason Im getting EXEC_BAD_ACCESS when trying to set an NSNumber property on a custom class. Think Im having one of those days! Here…
Anthony Main
  • 6,039
  • 12
  • 64
  • 89
0
votes
2 answers

Unable to debug EXC BAD ACCESS Code 1

Thanks for checking out my post. So on line image!.drawInRect(rect!), I get the EXC_BAD_ACCESS Code 1 error and I can't figure it out for the life of me. I have enabled Zombies in the Run Scheme, and nothing prints out (maybe I'm doing that wrong…
justColbs
  • 1,504
  • 2
  • 18
  • 28
0
votes
2 answers

EXC_BAD_ACCESS in for loop

Can anyone enlighten me as to why i'm getting an EXC_BAD_ACCESS on this chunk of code? I ran Instruments with Allocations and NSZombie enabled, and it said i messaged a zombie, but can't see whats up with it. NSMutableArray *keys = [NSMutableArray…
joec
  • 3,533
  • 10
  • 60
  • 89
0
votes
2 answers

EXC_BAD_ACCESS when loading NSArray from .plist

I have a plist written from a NSMutableArray by [NSMutableArray writeToFile]. When trying to load that same plist with the following code: NSArray *testArray = [NSArray arrayWithContentsOfFile:[self…
Tobias
  • 27
  • 1
  • 6
0
votes
3 answers

XCode building: identical configurations behave differently

I have a superweird problem: I get a crash (EXC_BAD_ACCESS) when running my app with Release as active configuration on my 3.1.3 iPhone 3G. (works well in debug configuration or in simulator , works perfectly on device running iOS4). My first guess…
Thomas
  • 547
  • 5
  • 12
0
votes
1 answer

Drawing a Circle with OpenGL

I'm trying to manipulate some code to draw a circle instead of the triangle that is already being printed by the tutorial. I'm not super familiar with C++ or OpenGL, which is why I'm just trying it out. Any suggestions or corrections to my code…
Maggie S.
  • 1,076
  • 4
  • 20
  • 30
0
votes
2 answers

Releasing modal view content controller causes: CALayer release - message sent to deallocated instance

I'm trying to present a viewcontroller modally: - (IBAction)addReference { ReferenceAddViewController *referenceAddViewController = [[ReferenceAddViewController alloc] initWithNibName:@"ReferenceAddViewController" bundle:nil]; …
redshift5
  • 1,966
  • 1
  • 18
  • 27
1 2 3
99
100