0
votes

I have a problem running an app on iOS 5 which works fine on iOS 4.3. I havnt converted the project to ARC so ARC should be completely disabled and as far as I understood the app should run like it always has with manual reference counting? It is currently crashing after the dealloc method (after [super dealloc] has been called), more precicely it gets a EXC_BAD_ACCESS on this part:

int main(int argc, char *argv[]) {

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

int retVal = UIApplicationMain(argc, argv, nil, nil); //EXC_BAD_ACCESS

[pool release];

return retVal;

}

I have tried to convert to ARC, but this is currently not possible as a I have third party JSON library which is unsupported. I have tried to put the compiler flag on all the appropriate files:

-fno-objc-arc

However this doesnt make any difference when trying the convert into ARC as the same errors appear as before and furthermore Xcode removes the flags from the files after the failed attempt.

Does anyone know what is going on here? I would assume if ARC is disabled then calls such as release should be fine?

2

2 Answers

4
votes

Sounds like a framework change from iOS 4 to iOS 5.0 means that you're hitting a dangling pointer. The EXEC_BAD_ACCESS in main is usually a sign of an object in the autorelease pool already being dealloced i.e. it has been over released or under retained.

I came across this same issue with UIImagePickerController in one of my projects.

Zombies are a good way to investigate autorelease problems. To turn on Zombies in Xcode 4.1 or 4.2 there's a checkbox on the "Diagnostics" tab of the "Run" stage called "Enable Zombie Objects".

With Zombies enabled when you should get an exception in the console where you were previously hitting EXEC_BAD_ACCESS. This exception will tell you information about the object.

1
votes

I found the problem, I was setting the class as a delegate of something else, the problem was resolved when I set the delegate to nil in the dealloc method. This was completely ignored in iOS4, but seems like iOS5 is more sensitive to these things. Thanks for your help!