开发者

EXC_BAD_ACCESS error thrown in xcode

开发者 https://www.devze.com 2023-03-31 02:51 出处:网络
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

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[])
{
    NSAutorelease开发者_如何学CPool *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.


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.


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 ;) ).

0

精彩评论

暂无评论...
验证码 换一张
取 消