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

EXC_BAD_ACCESS (code=1) on iPad 2, iPhone4S and iPhone5 only

this has been bugging me all morning, I have searched the hell out of this website and I can't find any reference to this issue. Within my project I have 2 objects with circular dependancies set up exactly like this; ClassA.h @class…
0
votes
1 answer

Problem resigning UISearchBar's firstResponder status

I've got a UISearchBar on my UITableView and a method -finishSearching which looks like this: - (void)finishSearching { [overlayViewController.view removeFromSuperview]; if ([sb isFirstResponder]) [sb resignFirstResponder]; …
flohei
  • 5,248
  • 10
  • 36
  • 61
0
votes
1 answer

crash when switching between tableviews using tab controller and MBProgressHUD

I have two tableviews. One loads when I select one tab, and the other loads when I select the other tab. I use MBProgressHUD to allow for quick switching between the tabs as I pull the tableview datasource from the web using Objective Resource and…
theprojectabot
  • 1,163
  • 12
  • 19
0
votes
2 answers

iPhone: App crash in MapView after 20 min

I am working on an app that tracks a users location. After about 20 minutes it seems that the app always crashes, and I am not sure why. Device logs show: Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at…
Nic Hubbard
  • 41,587
  • 63
  • 251
  • 412
0
votes
1 answer

iphone EXC_BAD_ACCESS using my own class

I made my own class derived by NSObject, and here is my code: -(void) parseRow:(NSDictionary*) dictionary { NSArray* arName = [[dictionary valueForKey:displayname] componentsSeparatedByString:@"+"]; [self setDriverName:[arName…
ghiboz
  • 7,863
  • 21
  • 85
  • 131
0
votes
3 answers

EXC_BAD_ACCESS while passing array to new ViewController

I'm loading some XML from a webservice (car data), create some car objects and would like to display them in a TableViewController. When the user has selected start and destination location, I'm making an async call to the webservice, show an…
productioncoder
  • 4,225
  • 2
  • 39
  • 65
0
votes
1 answer

Cannot resolve EXC_BAD_ACCESS (code=EXC_I386_GBFLT)

I'm very new at C++, maintaining my M.Sc on Information Systems. I have my first C++ homework announced and have been working on it for a couple of days. The aim of the code is simply to read info from a text file and print it on screen, then make…
Basak Oguz
  • 17
  • 7
0
votes
1 answer

Swift EXC_BAD_ACCESS on variable with existing allocation

I have a question about the attached error message. It is showing an EXC_BAD_ACCESS code around the variable closeTree1, defined below: let closeTree1 = SKSpriteNode(texture: SKTexture(imageNamed: "tree1")) As you can see at the bottom of the…
jelmore
  • 1
  • 3
0
votes
1 answer

Getting EXC_BAD_ACCESS error (code = 1) when posting a notification with Notification Center

I have a view controller with this method: - (void)getImages { if (self.myEntities != nil) { if (self.myEntities.count > 0) { if (self.imagesDownloader == nil) { self.imagesDownloader = [[ImagesDownloader alloc]…
AppsDev
  • 12,319
  • 23
  • 93
  • 186
0
votes
2 answers

EXC_BAD_ACCESS exception at Reachability class

I'm using the Reachability class provided here by Apple in my iOS project. I call its currentReachabilityStatus method always before trying to call my own REST web services: - (NetworkStatus)currentReachabilityStatus { NSAssert(_reachabilityRef…
AppsDev
  • 12,319
  • 23
  • 93
  • 186
0
votes
1 answer

NSTextField binding causes EXC_BAD_ACCESS

I have an NSTextField which is bound to an int in an object that I have included in my nib. When the object changes its int, the text field follows suit, and everything looks fine. However, when I try to change it manually the program crashes as…
Brian Postow
  • 11,709
  • 17
  • 81
  • 125
0
votes
0 answers

EXC_BAD_ACCESS on alloc

If this issue has been posted before, I can't find it. I'm attempting to allocate and initialize an instance of NSString in the initialization method of a subclass of NSOperation (for use with NSOperationQueue). The NSString pointer is an ivar (not…
0
votes
2 answers

My subclass as a property won't accept new values for its properties

I have a UIViewController that presents another UIViewController with a picker and returns four values. I also have a custom class called Chemical that can hold these values. In the delegate method that receives the values (the didSelectSource one…
Steve
  • 6,332
  • 11
  • 41
  • 53
0
votes
0 answers

Why am I getting this EXC_BAD_ACCESS error in Swift, but not in Objective-C? Cannot pinpoint it

Example project: http://cl.ly/360k3M3a2y05 I'm playing with the Reddit API for a school project, and came across this library for using it in Objective-C/Swift. The professor wants us to get our toes wet with Swift, which I'm happy to do, and the…
Doug Smith
  • 29,668
  • 57
  • 204
  • 388
0
votes
1 answer

iOS [UIImage imageWithContentsOfFile:filePath] EXC_BAD_ACCESS issue

Here is the code below. It downloads a thumbnail image and then tries to create an image based on the thumbnail file path. But it gives me EXC_BAD_ACCESS error at method call "imageWithContentsOfFile". While EXC_BAD_ACCESS addresses the code trying…
JohnnL
  • 111
  • 11
1 2 3
99
100