IssamTP
IssamTP

Reputation: 2440

iPhone EXC_BAD_ACCESS after the viewDidAppear event

I need an hint on where to search for detecting what causes a Crash with message EXC_BAD_ACCESS, which it should be related to "retain - release" questions. It happens in a moment AFTER the event viewDidAppear.

0   0x01285a63 in objc_msgSend  
1   0x0580e400 in ??  
2   0x0105fb8d in _ CFAutoreleasePoolPop  
3   0x00022443 in -[NSAutoreleasePool release]  
4   0x002d3bf2 in _ UIApplicationHandleEvent  
5   0x018cca36 in PurpleEventCallback  
6   0x01105064 in __ CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__  
7   0x010656f7 in __CFRunLoopDoSource1  
8   0x01062983 in __CFRunLoopRun  
9   0x01062240 in CFRunLoopRunSpecific  
10  0x01062161 in CFRunLoopRunInMode  
11  0x002cafa8 in -[UIApplication _run]  
12  0x002d742e in UIApplicationMain  
13  0x00001ca0 in main at main.m:14

The strange thing is that it doesn't happen always, just sometimes; I've checked the whole class that is first launched, but I can't see anything that may cause this trouble. In addition to that, if I dig step by step with the debugger, it seems that the problem never occurs, maybe a simulator problem?

Upvotes: 0

Views: 1316

Answers (2)

Erik B
Erik B

Reputation: 42594

It looks to me like the autorelease pool is trying to release an object that is already deallocated. I guess NSZombie would help finding the object in question.

EDIT: To activate NSZombie do the following:

  1. Get info of the executable.
  2. Go to the arguments tab.
  3. In the "Variables to be set in the environment:" section add:

Name: NSZombieEnabled Value: YES

Then run your app as usual and when it crashes it should tell you which deallocated object received the release message.

Upvotes: 3

Eimantas
Eimantas

Reputation: 49354

Not an answer, but a tip - compile the app for the simulator, launch the Instruments and add memory allocation tool with "NSZombies enabled" from library. Run the app in instruments until you get a notice about sent message to zombie object.

Upvotes: 3

Related Questions