EXC_BAD_ACCESS 🍎 iOS

Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)

The app accessed memory it shouldn’t — a dangling pointer, released object, unsafe pointer misuse, a data race, or infinite recursion (stack overflow).

Seen on: iOS

Meaning

In Swift it often comes from unowned references to deallocated objects, Unsafe pointers, Objective-C interop, or concurrent mutation. code=2 with a deep stack usually means infinite recursion. Zombies and Address/Thread Sanitizer pinpoint it.

Common causes

  • Accessing a deallocated object (unowned/unsafe reference, delegate not weak/strong properly)
  • Infinite recursion overflowing the stack
  • Data race on shared state
  • Misused UnsafePointer / C interop

⚡ Quick fix

  1. Enable Zombie Objects and Address Sanitizer in the scheme
  2. Look at the stack for recursion
  3. Enable Thread Sanitizer for races

Detailed fix by platform

Xcode

  1. # Product → Scheme → Edit Scheme → Run → Diagnostics → Address Sanitizer, Thread Sanitizer, Zombie Objects

How to diagnose

  1. Stack — Repeating frames (recursion)?
  2. Object — Which object was released?
  3. Threads — Concurrent access?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.