3

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...

Cœur
  • 37,241
  • 25
  • 195
  • 267
BeMyGuestPlease
  • 531
  • 1
  • 4
  • 13

5 Answers5

2

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.

Zoleas
  • 4,869
  • 1
  • 21
  • 33
  • Thanks Zoleas. It´s true that you must call super but that didn´t resolve the issue. The above code is just an example and seems to happen in every viewXXX methods, in any project now with the new updates (XCode and debugger). Your comment was very helpful anyway reminding me to call super there. Thanks! – BeMyGuestPlease Oct 14 '11 at 15:12
2

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

Lefteris
  • 14,550
  • 2
  • 56
  • 95
  • Thanks @Lefteris. The code in the example isn´t really important. The thing is that happens with every viewXXX method and only while debugging. This didn´t happen before XCode 4.2... Zombies enabled and already tried that. What do you mean with setting an malloc_error_break? How do you do that? Thanks!! – BeMyGuestPlease Oct 15 '11 at 13:03
  • Hi, Look at this: http://stackoverflow.com/questions/971249/how-to-find-the-cause-of-a-malloc-double-free-error Since you say this is happening in every method, is this happening also with sample code from Apple? Or you mean in your App? – Lefteris Oct 16 '11 at 15:02
  • Just tested it with a sample code from Apple and can´t reproduce the problem... You are right! Seems to be in my code... – BeMyGuestPlease Oct 18 '11 at 10:18
  • Check your project settings then and make sure you are using the correct Compiler and project settings. Compare your project settings with those from the Apple Sample App and see what might be doing this – Lefteris Oct 18 '11 at 11:08
2

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];
}
Ken
  • 30,811
  • 34
  • 116
  • 155
  • Thanks. Just edited the question. Code includes super. This happens with any project (empty one or already functional one). This happens with any viewXXXX method and only when debugging. – BeMyGuestPlease Oct 15 '11 at 13:01
2

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.

RachelD
  • 4,072
  • 9
  • 40
  • 68
0

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)

bioffe
  • 6,283
  • 3
  • 50
  • 65