Reputation: 428
I had an app that used to work fine in ios4 and earlier os but I'm now seeing frequent EXC_BAD_ACCESS while trying to run it on the simulator for ios5. Unfortunately, I'm now on xcode 4.2 and I'm unable to see my zombie objects when I get an error.
The app never crashes on the phone but it consistently crashes on the simulator so I want to see what's causing the crash before submitting an update. Whenever I get the error (and it's happening from multiple views), I get
int retVal = UIApplicationMain(argc, argv, nil, nil); Thread 1: Program received signal: "EXC_BAD_ACCESS"
I'm enabled NSZombie both from the diagnostics screen and the variables tab and yet I still can't see anything. Even adding a line in didFinishLaunchingWithOptions which purpossely releases the same object several times gives me this error at launch but never gets reported as an NSZombie.
What am I doing wrong?
Also, when these errors happen, this is what I see in the debug window. This looks like the stack trace but is there any way I can get line numbers with it?
#0 0x020b609b in objc_msgSend ()
#1 0x002ba9d0 in -[NSURLConnectionInternal initWithInfo:] ()
#2 0x002bb4df in -[NSURLConnectionInternalConnection initWithInfo:] ()
#3 0x002ba0af in -[NSURLConnection(Private) _initWithRequest:delegate:usesCache:maxContentLength:startImmediately:connectionProperties:] ()
#4 0x002ba1f6 in -[NSURLConnection initWithRequest:delegate:] ()
#5 0x002ba17b in +[NSURLConnection connectionWithRequest:delegate:] ()
#6 0x01f13d81 in +[NSObject performSelector:withObject:] ()
#7 0x001df9ef in __NSThreadPerformPerform ()
#8 0x01ee697f in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#9 0x01e49b73 in __CFRunLoopDoSources0 ()
#10 0x01e49454 in __CFRunLoopRun ()
#11 0x01e48db4 in CFRunLoopRunSpecific ()
#12 0x01e48ccb in CFRunLoopRunInMode ()
#13 0x02775879 in GSEventRunModal ()
#14 0x0277593e in GSEventRun ()
#15 0x00516a9b in UIApplicationMain ()
#16 0x00055919 in main at /Volumes/Data/xxxx/Classes/internal/main.m:14
#17 0x00002d75 in start ()
Upvotes: 0
Views: 635
Reputation: 104708
It's usually easiest to debug zombies using Instruments. There is a preset/template instrument for this. Instruments will halt your program when a zombie is messaged, and you can even use it to review every ref count operation.
Upvotes: 1