8

I recently had my xcode upgraded to version 4, and I have an EXC_BAD_ACCESS exception in my code, but despite setting NSZombieEnabled in the environment it's still showing the break point on the thread1, int retVal = UIApplicationMain(argc, argv, nil, nil); line.

I'm sure I had this configured in XCode 3 to stop on the line of my code that was causing the exception. Now it doesn't do that and displays no error messages in the GDB window either.

Does anyone know what I might be missing?

Thanks Ray

Neeku
  • 3,646
  • 8
  • 33
  • 43
Ray Price
  • 81
  • 1
  • 2

1 Answers1

5

EXC_BAD_ACCESS is not an exception, at least not as far as breakpoints are concerned - it means the code is trying to call a method on an object that does not exist anymore, because you released it.

The easiest way to find this in XCode4 is to run Instruments (Cmd-I), and in the dialog that pops up asking you which instrument to use, choose "Zombies". Then do whatever to cause the crash, and you will see a dialog pop up with "Zombie Messaged". Click on the little arrow and you will get a history of what created, retained, or released the object. Then you can figure out who released the object early.

Kendall Helmstetter Gelner
  • 74,769
  • 26
  • 128
  • 150
  • I don't see any "Zombies" option in the instruments app that pops up. Is there any setting that I should change? – Ashish Awaghad Apr 15 '11 at 08:57
  • In XCode4 there should be a Zombies instrument, but it will only appear when running Instruments on the simulator (no Zombie detection on the device) – Kendall Helmstetter Gelner Apr 15 '11 at 15:55
  • 1
    Thanks. Turned out the zombies were working ok, but I had an example where I was trying to release an object that had never been allocated, so it didn't fit into the zombie model. I just had to do it the old fashioned way and step through the code line by line.Thanks for the reply though! :) – Ray Price Apr 15 '11 at 21:31
  • 1
    Interesting, good point that something that had never been allocated would not be a zombie. – Kendall Helmstetter Gelner Apr 16 '11 at 05:35