Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode won't step over crash

So, this has happened a number of times in a number of different projects. I'll be debugging my app in Xcode, when Xcode breaks on an error. After looking at it, I'd hit Step Over or Continue...and it wouldn't do anything. More accurately, it acted like it stepped, but didn't actually go anywhere. This can be repeated indefinitely, as far as I can tell. One reason this is problematic is that it never gives me the crash log, because it never finishes crashing. I only get the crash log when the app crashes and it isn't being debugged (which means I have to get it through Crittercism or by checking the device logs).

Anybody see this before, and/or know why it does this? I haven't seen any mention of this elsewhere, but it's happened to me in several projects.

For example, in one project we use SocketRocket, and every once in a while (for an as-of-yet unknown reason) it crashes in SRWebSocket.m in the following method:

- (void)main;
{
    @autoreleasepool {
        _runLoop = [NSRunLoop currentRunLoop];
        dispatch_group_leave(_waitGroup);

        NSTimer *timer = [[NSTimer alloc] initWithFireDate:[NSDate distantFuture] interval:0.0 target:nil selector:nil userInfo:nil repeats:NO];
        [_runLoop addTimer:timer forMode:NSDefaultRunLoopMode];

        int i = 0;

        while ([_runLoop runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]) {
            NSLog(@"_runLoop %i %@", i++, [NSDate date]);
        }
        assert(NO);
    }
}

It crashes on the while line. (I added the NSLog line, by the way). When I hit Continue or Step Over, the line indicator flickers briefly, then appears again on the same line. Note that it does not continue to the NSLog line, and nothing is written to the console at all. I'm currently still trying to get it to crash again (this particular crash is rather unpredictable), but if I remember correctly, the line indicator says EXC_BAD_ACCESS, probably a prematurely deallocated object.

like image 486
Erhannis Avatar asked Mar 07 '14 02:03

Erhannis


People also ask

How do I save Xcode crash?

Using the Xcode Organizer Open the Xcode Organizer window. (Window menu -> Organizer, or Cmd-Shift-2.) Find your device in the left sidebar, then select “device logs”. Choose a Chrome crash (or multiple crashes) and select “Export” at the bottom of the Organizer window.

How do I run debug in Xcode?

When you run an application in Xcode, the debugger is automatically started and attached to the process of the application. Click the Run button in the top left or press Command + R. From the moment the application is up and running, we can start inspecting the process and, if necessary, debug it.

What is debug executable in Xcode?

The “Debug executable” checkbox specifies whether or not you want to run with the debugger enabled. Once running, you can use Debug > Attach to Process on a process that has been launched with debugging disabled if needed. It seems like all this does is start your app with the debugger attached.


1 Answers

You're missing the point of Step Over. When you step over a line, you're saying execute the current line and go to the next visible one, regardless off whether the current line calls another procedure.

If the code crashes at any point, you will not be able to continue executing lines of code.

like image 61
woz Avatar answered Oct 06 '22 01:10

woz