0

My application crashes at various points while running, and result with the following error, in the same point in the code. My research indicates that this is a memory issue, but I am not sure why. I am not an app developer (rather a web developer), who has a decent understanding of Objective-C. I did not build this application either (Long Story).

#import <UIKit/UIKit.h>

int main(int argc, char *argv[])
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, nil);        //Crashes with EXC_BAD_ACCESS
    [pool release];
    return retVal;
}

I know it is probably tough without knowing the rest of the application, but can anyone point me in the right direction as to what could cause this, or how I may begin to debug it?

NOTE: The application was not throwing this error until I fixed some memory leak issues. Not sure if that helps.

Chris
  • 4,762
  • 3
  • 44
  • 79
  • Check your release calls. The problem is in them! Try to comment all and one by one uncomment them or use NSZombie class – Nekto Aug 28 '11 at 17:46

2 Answers2

3

The right direction is to use Instruments (comes with Xcode in the /Developer/Applications folder). If it's an EXC_BAD_ACCESS, your best bet is the Zombies instrument.

Joshua Nozzi
  • 60,946
  • 14
  • 140
  • 135
0

Depending on whether you are using Xcode 4 or an earlier version, SO answer found at How to enable NSZombie in Xcode? might be helpful; in your question the error is reported at the topmost level, hence as you thought that's not particularly useful to tell about the error source.

A two cents feedback I can provide you with is that I experienced something similar first time I tried the Static Analyzer; following its reports I tried to fix potential leaks, actually causing a resource to be freed ahead of time. The tool is helpful, but it needs more time to be mastered than it may seem at the beginning. It looks like as a push button, but it is not exactly, as the try-to-fix solution might look proper also when it is not (you just went beyond its abilities to analyze, making a more "subtle" mistake ;) ).

Community
  • 1
  • 1
Andrea Fedeli
  • 71
  • 1
  • 4
  • You don't have to enable NSZombie. Just run the app in Instruments with the Zombies instrument and you're all set with a very comprehensive GUI wrapper around DTrace. – Joshua Nozzi Aug 28 '11 at 20:07