1

I have a problem with debugging my xcode project. When my app crashes i get an unreadable stacktrace like this:

2011-10-25 10:03:29.966 fruehstueck[2541:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(0x352918bf 0x303ce1e5 0x351e620f 0x2c381 0x46f6d 0x3138f7ff 0x3139bc39 0x3139baa9 0x3139b98f 0x3139b211 0x3139af53 0x3138f673 0x3138f349 0x3a347 0x3aa87 0x351eb435 0x3147473f 0x3137050f 0x3136ff01 0x313564ed 0x31355d2d 0x3717be13 0x35265553 0x352654f5 0x35264343 0x351e74dd 0x351e73a5 0x3717afed 0x31384743 0x2e01 0x2dc0)

The Code itself doesn't stop in my sourcecode but in line "int retVal = ..." with an SIGBART signal received.

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

Can somebody please tell me if i can get back my used stacktrace, where at least I can look up in which line my app crashed?

Thx in advance, Maverick

Maverick1st
  • 3,774
  • 2
  • 34
  • 50

3 Answers3

1

Its fairly simple:

-[__NSArrayM insertObject:atIndex:]: object cannot be nil

If you want to track it down and you know the steps, it would not take too long to guess which "insertObject" call is being given a nil pointer.

For getting proper stack-trace, have you tried cleaning the build? Also, try with breakpoints on. (and make sure you are not using a beta version of XCode).

zakishaheen
  • 5,551
  • 1
  • 22
  • 29
  • what do you mean with "debug version of XCode"? – Maverick1st Oct 25 '11 at 08:32
  • Sorry I meant "beta". Edited the answer. – zakishaheen Oct 25 '11 at 08:35
  • hmm, problem with breakpoints is, that this error is occuring at random. I switch between viewcontrollers and after some switching the app crashes. But i don't get a memory warning, so i really have no idea, why it works the first 5 times for example and crashes the 6th time. I am not using a beta version of XCode. I'll try with a clean build now, but my hopes are low. – Maverick1st Oct 25 '11 at 08:41
  • See these posts I answered lately about crash analysis: http://stackoverflow.com/questions/7885682/app-rejected-strange-iphone-crash-log/7885936#7885936 http://stackoverflow.com/questions/7883721/crash-where-to-start/7885683#7885683 – zakishaheen Oct 25 '11 at 08:43
  • Nice post. I didn't make use of it with my problem i have right now, since i found an other solution to find out where my app crashes, but it will help me sometime else i think. :) I now found the line of code where it crashed by simply putting a pretty function log in every method which could be relevant. :) So your posting pushed me in the right direction. Thx for that. :) – Maverick1st Oct 25 '11 at 08:57
  • This must be an issue with the Xcode beta, my debugger is doing the same thing. It's a real pain. Even though I know where my code is breaking I would much rather Xcode take me there rather than dump my in the main function each time. Downloading the new release now. Hopefully that will fix it. – Daniel Wood Oct 25 '11 at 18:46
  • 5
    This isn't really a helpful comment. Telling people to 'guess' isn't actually all that helpful. What he's looking for is how to get Xcode to symoblicate the stack trace. It appears that the actual error message (or even this actual error) is not relevant to a question asking how to make stack traces readable. – rharter Nov 08 '12 at 16:22
1

You’re not assigning an app delegate to UIApplicationMain. Is this deliberate?

If not, and if you’re using Xcode 4.2 and iOS5 SDK your main must look like:

int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}
Jorge Ramos
  • 891
  • 10
  • 21
  • The project was started as an ios 4 project under xcode 4.0. I just used the template my company uses always. Is there a reason why my main should look like you wrote? – Maverick1st Oct 25 '11 at 08:31
  • When you use Xcode 4.2 and iOS5 SDK, you can use Automatic Reference Counting (ARC) feature. From Apple’s website: "Automatic Reference Counting (ARC) for Objective-C makes memory management the job of the compiler. By enabling ARC with the new Apple LLVM compiler, you will never need to type retain or release again, dramatically simplifying the development process, while reducing crashes and memory leaks. The compiler has a complete understanding of your objects, and releases each object the instant it is no longer used, so apps run as fast as ever, with predictable, smooth performance." – Jorge Ramos Oct 25 '11 at 08:34
  • Ok, but don't i have to refactor the whole project for this? – Maverick1st Oct 25 '11 at 08:35
  • I think not, but it’s best that you make a backup and try to use this option. – Jorge Ramos Oct 25 '11 at 08:38
  • And i wont have downwardscompatibility to ios 3.2 if i use ARC, right? A.F.A.I.K. i do at least have to refactor all my @synthesize statements. May be i should read a bit more about ARC before. – Maverick1st Oct 25 '11 at 08:43
  • Yes, I recommend you to read more about ARC. You’ll maintain all the compatibilities because ARC is just a compiler feature. It will do memory management for you. Just try it, it’s awesome :) – Jorge Ramos Oct 25 '11 at 08:46
  • I'll definitely try it with my next project or at the next update of my current project. But right now i don't have the time to do it i think. But thx for the info. It was quite useful for me and thus you too get one up, even if the other answer hinted me to the solution for my problem. :) – Maverick1st Oct 25 '11 at 09:00
0

From what I've seen you can't actually symbolicate the call stack anymore, but you can work around the issue. Check out this answer if you don't mind changing your application code or use the graphical call stack in the Xcode window's Debug Navigator.

Community
  • 1
  • 1
rharter
  • 2,495
  • 18
  • 34