2

My app is crashing and getting an EXC_ARITHMETIC error and I don't know why. Here is where the error is happening:

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

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

The error happens when I click a button in the app, it's hooked up in my ViewController.m file like this:

- (IBAction)btnPressed:(UIButton *)sender {
    [self btnPressed];
}

Which calls this code from the same file:

- (void)btnPressed {
    NSString *strInfo = [[NSString alloc] initWithString:@"Test Info. \r\n"];
    NSData *dataInfo = [strInfo dataUsingEncoding:NSUTF8StringEncoding];
    [strInfo release];
    [socket writeData:dataInfo withTimeout:-1 tag:1];
}

The btnPressed is also called when the app loads and it DOES NOT produce an error. As well if I add a breakpoint to the [self btnPressed]; line then when I click the button in the app it works, stops at the breakpoint and when I click 'continue program execution' it works without error as well.

Note: I'm using CocoaAsyncSocket to communicate with a Cocoa app.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
tsdexter
  • 2,911
  • 4
  • 36
  • 59
  • 2
    Have you tried running in the debugger without any breakpoints? When the exception occurs you can then look at the stack trace to see what's going on at the exact time of the error. – nall Oct 09 '11 at 16:25
  • This the debugger output I get... GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 15 16:03:10 UTC 2011) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "x86_64-apple-darwin".sharedlibrary apply-load-rules all Attaching to process 7426. Current language: auto; currently objective-c (gdb) – tsdexter Oct 09 '11 at 16:46
  • I think this is potentially a problem with the iOS 5 sdk? It seems to be running without a hitch in iOS 4.3 simulator – tsdexter Oct 09 '11 at 17:37

1 Answers1

0

This seems to be only a problem with iOS 5 sim, running fine in iOS 4.3.

tsdexter
  • 2,911
  • 4
  • 36
  • 59