Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EXC_BAD_access code=2 address 0x8

I have an app that I've been working on, which worked perfectly on iOS 6 in XCode 4.5, but now I downloaded XCode 5 with iOS 7 and get this error,

Thread 1: EXC_BAD_access code=2 address 0x8

in main.m :

#import <UIKit/UIKit.h>
#import "TestAppDelegate.h"

int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([TestAppDelegate class]));
    }
}

I downloaded iOS 6 sdk and the code work perfect on iOS 6 sdk yet but with iOS 7 , i get this error , and I don't know why? I try to debug this but get no information about the crash. I read something about zombies and enabled it by going to Product->Edit Schema->Diagnostic->Enable Zombie Object. But even after this I didn't get anything helpful.

Any pointers?

like image 237
hossein1448 Avatar asked Sep 23 '13 06:09

hossein1448


2 Answers

I'd like to expand on the tip given by Vinzzz but differing slightly (exception not symbolic breakpoint).

The problem here is that the program has stopping on an OS caught exception (bad access). You need to go one step earlier than this, to see the exception in code which would lead to an iOS exception. Go to the breakpoints tab on the left Xcode screen panel section (Breakpoint Navigator). Then at the bottom of the panel there should be a + sign. Click there and add an 'Exception Breakpoint'. Re-run your program and you should now be breakpointed when the problem is attempted to be introduced into the OS environment. This gives information about who and what is the cause.

like image 144
Faisal Memon Avatar answered Nov 01 '22 21:11

Faisal Memon


When you get to the (lldb) prompt try to hit the continue button. That may reveal the underlying error message in the top of the debugger console. Look for the top of the bold text to see what possible object is causing the problem. This type of error usually refers to an attempt to access an object that has been deallocated.

like image 1
Tommie C. Avatar answered Nov 01 '22 21:11

Tommie C.