Help debugging crash on iOS EXC_BAD_ACCESS

Hi,

I know this was asked a lot with different causes. I have read all that I could find on the subject, but I am still stuck - so any help would be greatly appreciated.

Here is the story:

  1. Upgraded Unity from 3.5.7 to 4.2.
  2. Successfully upgraded my project (all the SetActive stuff mostly)
  3. The project runs in the Editor, no errors.
  4. The project used to run with Unity 3.5.7 on the device with no problems.
  5. I am now getting a crash with EXC_BAD_ACCESS when I load my third scene.
  6. I have enabled NSZombies in Xcode to try and better understand whats going on, its still cryptic for me.
  7. I have tried attaching MonoDevelop debugger, but I didn’t see anything I can use (I am not usually using MonoDevelop so I could be missing some debug technique).
  8. The exact same thing happened to me with another project, when upgraded to an older Unity 4 version (and this was the reason I avoided upgrading for so long).
  9. UPDATE: Managed to get it to not crash in the simulator, still crashing on the device.
  10. UPDATE: I have created an “export package” for my entire project, and reloaded it into a new blank project. At first, it seemed to be working, but then I realized it still crashes, only at a different place now…
  11. UPDATE: I since managed to eliminate the crash, it is caused by a bug in Unity 4.2 where DewviceID is not retained. I have learned it from this forum thread, and I am waiting for either Unity support or a more advanced user to post an authoritative fix for us to implement in the DeviceSettings.mm file (for DeviceID, VendorID, and ADID)

Finally, here are two screenshots: One, without NSZombies (generating EXC_BAD_ACCESS) and one with NSZombies (generating EXC_BREAKPOINT - needless to say, I did not place any breakpoint…)

Without NSZombies:

With NSZombies:

Ok,

So as it turns out, this particular crash was caused by a bug in Unity 4.2, as discussed in this forum thread.

After retaining the _DeviceID, all worked smoothly, and as it seems from the changelog, Unity 4.2.1 fixes this bug.