Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iphone app crashes without any console errors or crash logs:

I am newbie here. i am trying to build a quiz app and while my app runs fine for the first iteration of the quiz it exits without any console errors on the second run. PAsting all the code below for reference.

It seems like when i re-run the quiz, -(void) loadNextWord function below does execute but nothing happens after that.

Please help!

Thank you!

Dump from the debugger:

My line 14 in main func is int retVal = UIApplicationMain(argc, argv, nil, nil);

#import <UIKit/UIKit.h>

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

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

Program received signal:  “EXC_BAD_ACCESS”.
(gdb)
#0  0x025f0907 in objc_msgSend ()
#1  0x05f28da0 in ?? ()
#2  0x023cfc9d in _CFAutoreleasePoolPop ()
#3  0x0001ee67 in -[NSAutoreleasePool release] ()
#4  0x002cfe7f in _UIApplicationHandleEvent ()
#5  0x02d73822 in PurpleEventCallback ()
#6  0x02474ff4 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#7  0x023d5807 in __CFRunLoopDoSource1 ()
#8  0x023d2a93 in __CFRunLoopRun ()
#9  0x023d2350 in CFRunLoopRunSpecific ()
#10 0x023d2271 in CFRunLoopRunInMode ()
#11 0x02d7200c in GSEventRunModal ()
#12 0x02d720d1 in GSEventRun ()
#13 0x002d3af2 in UIApplicationMain ()
#14 0x00002880 in main (argc=1, argv=0xbfffef94) at /Users/vbhardwaj/Documents/ObjectiveC/FinalProject/FunWords/main.m:14
like image 849
Vatsal Bhardwaj Avatar asked Dec 05 '10 08:12

Vatsal Bhardwaj


1 Answers

Looking at the stack trace you see the line

[NSAutoreleasePool release]

This tells me that you have released an object too many times i.e. something like :

NSString *string = [NSString stringWithString:@"Hello"]; // This string is autoreleased
[string release]; // This line won't crash but is WRONG!

The above code will not crash immediately but the string will be released and dealloc'd. However, because it's also autoreleased the autorelease pool will try to release it again at some point in the future. You don't know when and will get a random crash.

You've probably done something like that :)

like image 117
deanWombourne Avatar answered Oct 14 '22 06:10

deanWombourne