36

Having a hard time tracking down a crash in an iPad application. The difficulty really stems from the fact that there is no errors or stack trace present when the application fails. It simply goes away like Keiser Soze, "And like that, poof. He's gone.".

I've replicated the crash on both the simulator and the device. There are zero device logs, nothing in the console, etc.

I know that during the crash some CoreGraphics operations are occurring in a background thread. Typically, three or so NSOperations are kicking of some image blends.

The blending consists of CGContext* calls (DrawImage, SetBlendMode, SetAlpha, etc). The NSOperation calls back to a delegate in the main thread to handle the image and set it to UIImage, so it shouldn't be a UI main thread conflict, but I'm not discounting anything at this point.

Are there some Xcode tricks I'm missing to track down exactly what is happening? Or at least get a better hint of where the problem lies?

EDIT I have run the app in Instruments tracking memory usage and see that it is pretty rock steady around 2MB. So, don't think it's a memory issue. But after consideration, this rock steady 2MB seems abnormally low. Is there a chance Instruments is not picking up the CoreGraphics allocations?

Alex Cio
  • 6,014
  • 5
  • 44
  • 74
MarkPowell
  • 16,482
  • 7
  • 61
  • 77
  • 1
    I've never done any iOS *development*, but when iOS apps started crashing on me (and not leaving any logs), it ended up being a low memory issue: closing all apps and rebooting the device cleared up everything. – Ken Jan 26 '11 at 21:44
  • @Ken - added an edit related to low memory. Thanks. – MarkPowell Jan 26 '11 at 21:50
  • Make sure you aren't just running the app, but debugging it. To verify, make sure Breakpoints are on. – Evan Mulawski Jan 26 '11 at 21:57
  • @Even Mulawski: Confirmed breakpoints were on (set on in delegate on load, it was hit). – MarkPowell Jan 26 '11 at 22:04
  • 2
    Re: low memory. Try sticking an NSLog or breakpoint in the applicationDidReceiveMemoryWarning delegate method, just to rule it out. Actually, it might be the case that XCode would output something to the console in this case, anyway. – Dave Jan 26 '11 at 23:32
  • 2
    Same situation here, app crashes but there's no crash log, debugger not stopped. No idea what's going on. According to Instruments memory consumption looks fine. – Michal Jul 08 '11 at 13:15
  • I'm upvoting this post purely for the mention of Kaiser Soze. that made me laugh. – Dave Dopson Dec 20 '11 at 06:12
  • This might happen if you are releasing (e.g. calling CFRelease) an object that you should not release. – DARKMATTER Nov 25 '20 at 23:51

6 Answers6

29

Try reading the registers.

Whenever my app crashes without error, in most cases I have found the exception in the registers.

First go to Exceptions tab and 'Add Exception Breakpoint' using the + at the bottom left corner. enter image description here

Then when the app crashes click on "0 objc_exception_throw" under Thread 1 enter image description here

Finally in the console enter:

  • register read (you should get a list of registers)

  • po $rax (normally the exception is in 'rax')

    (you should see the exception output on the console)

Hope this helps.

Community
  • 1
  • 1
shrishaster
  • 682
  • 9
  • 21
10

For lack of a better solution, and if it isn't obvious, pepper your app with NSLogs to circle where this occurs, then drill deeper from there via breakpoints and/or additional logs.

fzwo
  • 9,842
  • 3
  • 37
  • 57
2

Super late answer, but I've found that using try/catch helps give information when I can't get a stack trace and my application pulls a Keiser Soze.

@try
{
  // suspected code causing crash/errors
}
@catch (NSException *exception)
{
  NSLog(@"Exception: %@", exception);
}
dragonflyesque
  • 485
  • 5
  • 11
  • 1
    for some reason I never saw this stuff work. Every time I have tried to used it the app crash the same way. No exception was ever caught for me. – Duck Apr 22 '17 at 22:56
  • 1
    Did you check out @Paul-Slocum answer below? Also, enabling zombie objects does not throw Objective C exceptions. Good answer here: http://stackoverflow.com/a/8738527/2907798. – dragonflyesque Apr 25 '17 at 13:27
  • YES. When I enable that, the app goes fine until the memory is exhausted and it crashes without messages or without providing a way to debug. Instruments shows no leak on my code but it is memory intensive. Because zombies keep elements allocated it will use all the memory and crash. – Duck Apr 25 '17 at 14:48
2

In my case, it was because of bad outlet connection in the storyboard. Check using breakpoint if viewDidLoad method of UIViewController to be loaded gets called. If not, check your outlet connections in the storyboard.

Incorrect connection crashes the app without any error or stack trace.

I am wondering what happened to the this class is not key value coding-compliant for the key error that used to show in older versions of XCode.

brainforked
  • 369
  • 4
  • 15
  • This is a recurring issue for me. Dozens of outlets and one is bad. Without a proper error message, it's like trying to find a needle in a haystack. :( – Albert Bori Jun 22 '17 at 17:37
1

In my case, it was because I had "Zombie Objects" enabled in the scheme to help find the problem, which was eventually causing it to run out of memory and crash.

Paul Slocum
  • 1,454
  • 13
  • 18
0

In my case it was due to an object being released. Normally it would say message sent to deallocated instance or something like that, but it didn't. I checked the iPhone's logs and found this: KERN_INVALID_ADDRESS, which I googled and came across this: KERN_INVALID_ADDRESS

Enabled zombie objects and found that I tried to use a deallocated instance. It also told me what object it was in the logs afterwards.

Hope it helps for future visitors.

Community
  • 1
  • 1
chrs
  • 5,906
  • 10
  • 43
  • 74