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

IBOutlet crashing with EXC_BAD_ACCESS even though not nil

In a UIViewController (rolePageController) I configure another UIViewController (drawerController) and pass it 2 UIViews from the role page that will be part of the drawerController's configuration. As soon as the drawerController tries to access…
18
votes
5 answers

NSDateFormatter crashes when used from different threads

We keep getting a random, weird crash with NSDateFormatter. The relevant stack trace is: Program received signal: “EXC_BAD_ACCESS”. #0 0x00000005 in ?? () #1 0x0213e3c3 in udat_parse () #2 0x01d4e1ca in CFDateFormatterGetAbsoluteTimeFromString…
jbenet
  • 3,030
  • 3
  • 22
  • 25
17
votes
2 answers

EXC_BAD_ACCESS when trying to build string by using %@ for an int

For the use within Core Data I tried to build a NSPredicate object. minLength and maxLength are of typeint: NSPredicate *predicate = [NSPredicate predicateWithFormat:@"length >= %@ AND length <= %@", minLength,…
Norbert
  • 4,239
  • 7
  • 37
  • 59
17
votes
1 answer

Stack overflow: Thread 1: EXC_BAD_ACCESS (code=2, address=0x16d09aa00)

Crash description Recently I'm facing kinda really strange memory issues in one of my iOS/Swift projects. I'm really not sure what's going on and feel it's also not quite easy to describe, but I'll try my best anyway. It basically behaves like…
d4Rk
  • 6,622
  • 5
  • 46
  • 60
16
votes
3 answers

"Thread 6 com.apple.NSURLConnectionLoader: Program received signal: EXC_BAD_ACCESS"

The app crashes about 15 seconds after launching and XCode just breaks at an address and gives me a pop up that says "Thread 6 com.apple.NSURLConnectionLoader: Program received signal: EXC_BAD_ACCESS" I've been totally unable to track the problem…
iamichi
  • 288
  • 1
  • 3
  • 9
16
votes
1 answer

EXC_BAD_ACCESS when copying or retaining Block

As far as I understand a Block acts like an object, in that you can send copy or release messages to it, e.g: [myBlock copy]; However whenever I do this, or release a block, I get EXC_BAD_ACCESS. If I use the block functions, everything works as…
Jonathan.
  • 53,997
  • 54
  • 186
  • 290
16
votes
2 answers

How can I remove all performSelector:withObject:afterDelay:?

I ran in to a EXC_BAD_ACCESS when deallocating an object that has few performSelector:withObject:afterDelay where the selector methods is calling another object and I am releasing the object. Somewhere in my class I am calling: [self…
Unis
  • 365
  • 1
  • 4
  • 13
15
votes
1 answer

How to solve KERN_INVALID_ADDRESS on EXC_BAD_ACCESS (SIGSEGV)

On my mac OSX snow leopard and xcode 4.1 and the last SDK, My application crash on my phone but on my phone friend it don't crash. I've got this error, I launch my application, wait RSS feed and after 2/3 seconds it crashed : Thank you for your…
Franck
  • 151
  • 1
  • 1
  • 3
15
votes
3 answers

How to find root cause Crashed: com.apple.main-thread in production app?

i have such a report from Crashlytics: Thread : Crashed: com.apple.main-thread 0 libobjc.A.dylib 0x000000019503fbd0 objc_msgSend + 16 1 CoreFoundation 0x00000001836e5458 CFRelease + 524 2 CoreFoundation …
Arnie Schwarzvogel
  • 955
  • 1
  • 13
  • 25
15
votes
7 answers

Iphone Core Data crashing on Save

I'm currently writing an Iphone application using Core Data and I get a EXC_BAD_ACCESS error during the [managedObjectContext save:&&error] code line. This crash only happens after I modify certain fields. More specifically my entity has two string…
kiyoshi
  • 837
  • 1
  • 8
  • 20
14
votes
1 answer

NSMutableAttributedString initWithData: causing EXC_BAD_ACCESS on rotation

I display different types of contents in a tableview and calculate the height of each cell using different custom methods, in heightForRowAtIndexPath. One of these custom methods implies converting some html in an NSMutableAttributedString, and then…
macbeb
  • 227
  • 2
  • 11
14
votes
1 answer

EXC_BAD_ACCESS automatic handling

I'm trying to build my own signal and uncaught exception handler for iOS. To do this i use these two functions : NSSetUncaughtExceptionHandler(/*handler*/); and signal(/*signal const*/, /*signal handler*/); My problem is that i can't make it…
animal_chin
  • 6,610
  • 9
  • 37
  • 41
13
votes
7 answers

Stopping at breakpoints causing EXC_BAD_ACCESS

My app runs fine and as expected, but for some reason when I place breakpoints, stepping into/over/resuming causes the program to crash with EXC_BAD_ACCESS. This does not happen if I remove/disable breakpoints. Any advice?
Dann
  • 323
  • 5
  • 17
13
votes
2 answers

Crash in actionForLayer:forKey:

I have a cryptic EXC_BAD_ACCESS when changing some UILabel's frame. The crash is random, usually I have to repeat the conditions for several minutes. Enabling NSZombies, as well as other memory debug flags (NSDebugEnabled, MallocStackLogging),…
Eino Gourdin
  • 4,169
  • 3
  • 39
  • 67
13
votes
2 answers

exc_bad_access in Facebook sdk login Xcode 8 beta

recently I started adding my application IOS 10 features while I encountered a weird bug: When authenticating with facebook SDK via browser as soon as I click the confirmation button in facebook itself at the embeded browser, the app…
Liran Revivo
  • 1,143
  • 3
  • 15
  • 20