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
140
votes
18 answers

What's the meaning of exception code "EXC_I386_GPFLT"?

What's the meaning of exception code EXC_I386_GPFLT? Does its meaning vary according to the situation? In that case, I'm referring to exception type EXC_BAD_ACCESS with exception code EXC_I386_GPFLT The program is developed in Xcode 5.0.1, dealing…
Lewen
  • 1,823
  • 2
  • 15
  • 17
68
votes
6 answers

Post of NSNotificationCenter causing "EXC_BAD_ACCESS" exception

A UIViewController adds itself to the default center: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(editFood) name:@"editFood" object:nil]; Then a UITableView delegate NSObject posts a…
46
votes
10 answers

Break on EXC_BAD_ACCESS in Xcode?

I'm new to iPhone development and Xcode in general and have no idea how to begin troubleshooting an EXC_BAD_ACCESS signal. How can I get Xcode to break at the exact line that is causing the error? I can't seem to get Xcode to stop on the line…
jasonh
  • 29,297
  • 11
  • 59
  • 61
43
votes
2 answers

EXC_BAD_ACCESS code 2 on UIAlertView in iOS6

I'm trying to figure out why im getting this crash in my app. It works perfectly fine in Xcode 4.4 running in the simulator with ios5.1, but when i switch into xcode 4.5 and ios6 I'm getting an EXC_BAD_ACCESS code 2. Here is my code: - (void)…
Sean Danzeiser
  • 9,141
  • 12
  • 52
  • 90
36
votes
9 answers

UIScrollView EXC_BAD_ACCESS crash in iOS SDK

I have an iPhone SDK application that has several views that appear and disappear as the user creates content. After using the application on a device for a while, I get the following crash: Program received signal: “EXC_BAD_ACCESS”. (gdb)…
BP.
  • 10,033
  • 4
  • 34
  • 53
32
votes
2 answers

EXC_BAD_ACCESS tapping uisearchbar three times

I am trying to implement a search bar in a UICollectionView as a UICollectionViewReusableView This way I am not using a UISearchController but I am changing the datasource of the collectionview In my custom layout I am adding the searchbar this…
Phil Niedertscheider
  • 1,068
  • 11
  • 29
30
votes
2 answers

NSURLSession causing EXC_BAD_ACCESS

I've noticed that implementing NSURLSessionDataDelegate and starting a task will very occasionally throw an EXC_BAD_ACCESS. The actual calling method that gives the error seems to vary but always comes from CFNetwork. For the most part, the calling…
oliveroneill
  • 858
  • 9
  • 13
29
votes
4 answers

Bad Access on [UICollectionView setCollectionViewLayout:animated:]

I'm getting a strange crash in my UICollectionView. The crashing UICollectionView is embedded in an UICollectionView cell of another UICollectionView. I can't reproduce the issue, it seems to happen sometimes if the inner UICollectionView get's…
muffe
  • 2,285
  • 1
  • 19
  • 23
29
votes
6 answers

UIWebView EXC_BAD_ACCESS crash

I'm experiencing crashes of an app that uses UIWebView. Usually it's when page is not fully loaded and UIWebView is sent stopLoading selector. Or when UIWebView fully loaded page. I've got EXC_BAD_ACCESS. Stack looks like this: #0 0x95bb7688 in…
HARDWARRIOR
  • 841
  • 1
  • 8
  • 22
28
votes
1 answer

EXC_BAD_ACCESS when building nspredicate

I am calculating the number of months between a birthdate and today. With that number, I am building a predicate to fetch objects from core data. Although the number of months is calculated correctly (as the log shows), I am getting a EXC_BAD_ACCESS…
mrd
  • 4,561
  • 10
  • 54
  • 92
25
votes
4 answers

Getting info about bad memory address in LLDB

I am trying to debug an EXC_BAD_ACCESS in my iPhone app. It is crashing on a method call and on the line of the method is EXC_BAD_ACCESS (code=1, address = xxx). Before, I would have just used gdb info malloc-history to start debugging, but…
Ross Kimes
  • 1,234
  • 1
  • 12
  • 34
25
votes
5 answers

Is there a way to catch or handle EXC_BAD_ACCESS?

As far as I understand, EXC_BAD_ACCESS happens when you try to access bad memory (feel free to correct me if I'm wrong)? Is there a way to kind of catch it like in a try-catch in Java to prevent total app failure?
corgichu
  • 2,580
  • 3
  • 32
  • 46
24
votes
4 answers

Why is it an "exc_bad_access" and not a "run-time" or "compile-time" error?

Why is it an exc_bad_access and not a run-time or compile-time error? By mistake I wrote "@age" instead of @"age", and it sparked my curiosity. What I understand of exc_bad_access is that : Bad-Access is caused by a pointer (okay reference) that is…
user3721704
24
votes
3 answers

EXC_BAD_ACCESS with IBACTION

I have read a lot about this issue but mine still seems to be different somehow. So from what I understood, EXC_BAD_ACCESS occurs with memory management problems. The thing is, mine does not seem (! :)) to be there. The thing is, I simple added a…
Icky
  • 1,055
  • 1
  • 12
  • 30
20
votes
5 answers

Avoiding EXC_BAD_ACCESS when using the delegate pattern

A have a view controller, and it creates a "downloader" object, which has a reference to the view controller (as a delegate). The downloader calls back the view controller if it successfully downloads the item. This works fine as long as you stay on…
Kenny Winker
  • 11,919
  • 7
  • 56
  • 78
1
2 3
99 100