BeMyGuestPlease
BeMyGuestPlease

Reputation: 561

Xcode 4.2 debugging on a viewDidLoad or viewDidDisappear will end on a EXC_BAD_ACCESS

Xcode 4.2 debugging on a viewDidLoad or viewDidDisappear will end on a EXC_BAD_ACCESS

It breaks on that breakpoint but when continuing ("Continue program execution") it returns a: EXC_BAD_ACCESS (code=1, address=0x....) on Thread 1 (0 start). That did not happen in earlier versions.

Someone getting the same error? Somebody knows how to deal with it?

Code for the example would be a simple:

 - (void) viewDidDisappear:(BOOL)animated {  
       [super viewDidDisappear:animated];
        NSLog(@"View did dissapear");    
    }

When debugging on breakpoint (line with NSLog) it and then hitting on continue it will end on that EXC_BAD_ACCESS. If no breakpoint then everything works fine.

I am working with Xcode 4.2 Build 4D199 (OS X Lion 10.7.2). Using LLDB debugger.

UPDATE: put a break in all exceptions and it always ends on a Thread 8: EXC_BAD_ACCESS - 0x1f43: movl (%ebx), %eax - line 0: start....

UPDATE 2: played around with Xcode and I really don´t know why but know it works. No code changed... hmmm... strange...

Upvotes: 3

Views: 1411

Answers (5)

RachelD
RachelD

Reputation: 4089

I was recieving the same error on viewDidDisappear:animated - it turned out that I had a typo calling [self viewDidDisappear:animated]; instead of [super viewDidDisappear:animated];

Simple fix but not very noticeable at first. I was surprised it didn't give me a warning.

Upvotes: 2

bioffe
bioffe

Reputation: 6393

I see slightly different issue here. In my case(SnowLeopard 10.6.8, XCode 4.2, LLVM 3.0) it stops at the brake point, but XCode doesnt display any debugging info. I can see my stackrace in GDB fine, but local values are messed up. Interestingly i tried to use performSelectorOnMainThread: it can restore XCode debugging functions, but something corrupts active frame values.

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
        [self performSelectorOnMainThread:@selector(_destroyMarketBrowser) withObject:nil waitUntilDone:YES];

}

Btw: Everything works fine in simulator, the problem only occurs on real devices (5.0.1 or 5.1 Beta2)

Upvotes: 0

Ken
Ken

Reputation: 31161

You must always call through to super at some point in all of the viewWill... or viewDid... methods that you override. For example,

- (void) viewDidDisappear:(BOOL)animated {
        NSLog(@"View did disapear");
        [super viewDidDisappear:animated];
}

Upvotes: 2

Lefteris
Lefteris

Reputation: 14677

You are not helping much with that code you provided.

set an malloc_error_break and enable zombies and see if that leads to something

Upvotes: 2

Zoleas
Zoleas

Reputation: 4879

If you override this method, you must call super at some point in your implementation.

It's from the doc, I don't know if it's the problem that cause your BAD ACCES, but it's at least something you have to fix.

Upvotes: 2

Related Questions