iOS Crash without Error or Stack Trace - ios

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?

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.
Then when the app crashes click on "0 objc_exception_throw" under Thread 1
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.

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.

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);
}

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.

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.

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.

Related

Crashlytics: What does compiler-generated means?

I'm using Firebase Crashlytics to get crash reports from my iOS app and I get some crashes that I don't understand with a <compiler-generated> error message. I don't understand what causes this kind of crash.
When I look at the stack trace I get one or several lines with the compiler-generated error message too.
I've been searching but can't find the reason or reasons why this kind of crash happens. In this particular example here is the function where the crash happens (it doesn't say which line). From what I see I can only guess that it has to do with the fact that I'm using an index from an array on another array so it might be out of range... but I don't really know.
It makes it really hard to fix crashes cause I just can assume what might be wrong in my code. Plus if the problem is actually the range out of index thing, shouldn't it report the line where the crashes occurs ? I'm really trying to understand the compiler-generated thing more than solving this actual crash :)
Compiler-generated means code injected into final binary by swift compiler. This might be unrolled inline-type library function, optimisation things, etc. The crash-log on your screenshot just shows the top call of the failed execution stack, and in majority of cases it is not your code line (while there is the reason) but some standard function call (from library or autogenerated). So you have to investigate not just one first line, but complete back trace of crashed stack.

EXC_BAD_ACCESS around Springboard-snapshotting

From time to time, Xcode Crashes comes up with a crash that i cannot understand. I pasted the xccrashpoint to gist
It states, that Thread 12 crashed somewhere in CoreGraphics called by CorePDF, called by QuartzCore drawing some layers. This seems like OS-called code, maybe via thread 1 which is doing _saveSnapshotWithName. So i assume, that this happens when closing the app.
Does anyone have at least a rough idea what is going on here? Maybe someone saw something similar before and can give a hint about what is crashing…
There is nothing special in the app that would cause dramatically wrong behaviour when leaving the app (-> when a screenshot ist taken).
Exec bad errors occur when an attempt is made to access a object or memory location which is not yet initialized.
There might be a problem with an object which you are not defining global.
Check if there is any object you defining and initializing in a method and trying to access out of the scope.
For more details related to errors and crashes, please go through below link.
http://www.raywenderlich.com/10209/my-app-crashed-now-what-part-1

Alternative to NSZombie

I'm trying to debug an EXC_BAD_ACCESS crash using NSZombie. My app creates lots of large objects though and with NSZombie enabled they aren't getting released causing the app to crash in seconds. This means I can't even cause the EXC_BAD_ACCESS crash before the app crashes due to low memory.
Is there an alternative? Can I enable NSZombie on specific file instead of the entire project? How else could I debug this crash (I know it's caused by UIGestureRecognizer but I use them a lot so it doesn't narrow down the issue significantly).
Thanks.
Edit:
Thanks for the advice. I think I may have solved the issue and will report back after more testing.
Edit 2: Sovled the issue myself but selected the answer which seems like it would be a good solution to any similar issues in the future.
All I can think of is implementing it manually; create a proxy container that holds an object of type id and nominates that as -forwardingTargetForSelector: as well as getting it to respond to -isKindOfClass:, etc.
Disable ARC for the proxy and have it retain itself during init and check its own retainCount when nominating a forwarding target.
If the count is 1 then raise an exception or log a warning or whatever.
Have suspect classes wrap themselves in and return a proxy as the last line of their unit.
For possible bonus points, store [NSThread callStackSymbols] somewhere (probably on disk) during the proxy's unit so you can at least find out where the incorrectly managed object was created.
NSZombies was/is for apps that use their own memory management. If your app uses ARC then this won't help.
Create a new Breakpoint: All Exceptions
That should usually show you where you trigger the bad access.

Swift debug: app stops at breakpoints and doesn't crash

In the age of Objective C, when I had error in my code and run it I received green thread breakpoint, but if I push button "Continue program execution" in the Debug Area, my app crashes and shows me exact error description.
Right now I'm suffer from "breakpoint loop" which occurs if I push continue button it stops at the same place and never crash. App doesn't crash at all and I haven't got any app error description. This is really annoying me, Thread 1: EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT, subcode=0xe7ffdefe) isn't very useful information in point of view of good old fatal error descriptions and so on.
Is there a way to break this "breakpoint loop" and crash the app to see error description?
EDIT:
Note: here I used word breakpoint, I didn't mean breakpoints that was set by myself, I meant default runtime crash breakpoints. Here is image of it (correct my if I named it wrong):
My breakpoint navigator:
The EXC_BREAKPOINT exception just means that the program tried to execute some particular "trap" instruction. That happens to be the instruction that debuggers use to set breakpoints. However, there are a number of system components that also use the trap instruction to halt execution when the program hits some exceptional condition. The idea being that if you are in the debugger, your app will stop and you can analyze the problem, but if not the app will die at that point.
You can tell whether the debugger is responsible for the trap because if lldb recognizes the EXC_BREAKPOINT as coming from a trap that it inserted, then it will tell you the stop reason was "breakpoint 1.1" or whatever - it won't show the raw EXC_BREAKPOINT as the stop reason. So if you are seeing EXC_BREAKPOINT it means you got some kind of internal assertion failure.
Usually you can tell what's going on by going to the bottom-most frame in the stack and looking at the code that has the trap inserted in it. Sometimes this isn't obvious in Xcode because if you stop for some exceptional reason in a stack where the bottom-most frames are assembly code, Xcode will select the lowest frame in the stack that has debug information. But if you look at the stack, you may see more frames below the stack.
You will also sometimes see little chunks of code that belong to your function, but come after the normal return instruction for you function. For instance, the stack guard mechanism will write a little error-handling section after some functions, and jump there and then trap if it notices stack overflow.

No source code on zombie stack trace from message to de-allocated instance of [CALayer]

I am hoping someone can assist in how to trace a message to a de-allocated instance of [CALayer] when the stack trace does not link back to the source code.
I have enabled Zombie Objects in the Diagnostics of XCode and run it through the Zombie profiling.
The response in XCode is "2013-01-27 22:37:31.506 AdventureA[9695:11303] *** -[CALayer release]: message sent to deallocated instance 0x757b530"
The response from the instruments is:
I am totally at a loss as to how to find out what is causing the issue; I have been looking through the source code for hours...
Ok - found it. There was a UIButton (which, of course, inherits from UIView) that was being instantiated as a buttonWithType and for I was releasing it. D'oh.
The reasons something so obvious became such a pain (for those who may have to deal with the same thing); the problem is that is all sounds so easy in hindsight:
I still have no idea why there is no stack trace that allowed me to
be able to track where the issue was happening.
With no source code being available from the Zombie output I was
directed to thinking this was something happening "under the covers"
I was looking at the View in place at the time the error was
happening when I should have been looking at the previous view which
was being affected by the de-allocation.
I had been coding since this morning...
Note the two calls to [UIView dealloc] in the caller list. Look at the allocations for UIView objects. You seem to have one with a strange lifecycle.

Resources