Debugging Crash in XCode - ios

I have an application & I am debugging that after some time I am getting below message in console logs
Message from debugger: Terminated due to signal 3
Program ended with exit code: 0
Can anyone help me in telling about this signal 3 log & how can I get rid of this?

Can anyone help me in telling about this signal 3 log & how can I get rid of this?
You'll generally also get a stack trace and probably a lot of other information. You may need to scroll in the console to see it. The stack trace will show you what methods were executing at the point when the crash happened, and there's typically also some indication of what kind of error occurred.

This could have several issues, but probably it will be a memory issue. Try to use Instruments to cover that problem.
Ctrl-click on our Xcode Icon in the Dock
Open Developer Tool
Instruments
Select Leaks (or at least Allocations)
Select your app and start the measurement

Related

Core Data info & error in console at runtime

I have met the following messages in the console at runtime, and i have no idea why. I have searched everywhere and nobody seems to meet this:
INFO: fetch-response is unable to open the file /Users/userName/Library/Application Support/iPhone Simulator/7.0.3/Applications/964A590B-7131-4BAE-958B-1783BEC193EF/Library/Caches/userName.AppName/fsCachedData/2F1A8708-35A9-491E-9C21-154BA428CA10. Errno: 2
ERROR: failed to mmap cache data from FS: /Users/userName/Library/Application Support/iPhone Simulator/7.0.3/Applications/964A590B-7131-4BAE-958B-1783BEC193EF/Library/Caches/userName.AppName/fsCachedData/83A968D1-0A2B-4D20-97D5-487A876649DC, errno:22
It does not seem to affect the execution though, but I suppose it is not a good sign. I am using Core Data with a timer which frequently updates the database from a server. These messages appear synchronously with the updates, but not systematically. Only one at the time, the "INFO" or the "ERROR". Reset Content and Settings in the Simulator did not solve the problem.
Does anyone have any idea about the meaning of these messages?
I experienced this when running on my device with an app I am building. It has worked perfect for weeks and then all of a sudden this error. I figured out that it is due to a lack of memory available on the device. I use a little app call "System Status" that allows you to view the memory stats and release any old unused memory. I only get this error in Xcode when I have less than 5% available memory on my device. Therefore it cannot load the cache file the app is request, hence the error. Either close all your multitasking apps and restart your device or get the app and free you memory.
After some testing/debugging (sorry for the delay), I have at least a temporary solution.
Because of the multi-threaded saving process of Core Data, I found it a little tricky to identify the exact error location, but it definitely appears that the error occurs when Core Data is trying to save one of the context in the stack (probably the last "root" one).
As each save take a few seconds (without freezing the UI :p) , I figured the error could be generated by a "save overlap".
So even if I do not have enough to be sure, reducing the save frequency effectively solved my problem: no message anymore in the output.
Now there still is a hitch, and any expert answer would be much appreciated!
Uninstalling the app from the device and installing it again removes this error message.
Note that that doesn't fix the problem if you can see this log from earlier versions of your app that is already on your users' devices. It's generally okay to uninstall-install, though, if you're only seeing this during the development phase.
For me this happened when my phone ran out of batteries and died as a result. Deleting the app, then restarting my phone, then rebuilding/installing solved the problem.
I ran into this error because my app was stuck in an infinite loop, doing network requests multiple times a second, causing the file to be overwritten before it could be read.
In the situation described in the original post, this might very well be the case.

Is it possible to debug "Terminated due to memory error"?

In a certain (consistent) point when my app is running, I consistently get the xcode error message
Terminated due to memory error.
I cannot find the code causing the error, but I can tell what code is near the error (using breakpoints).
The error is caused directly after returning a certain cell in my implemenation of the
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
UITableViewDataSource delegate method. I can confirm that it is returning a valid UITableViewCell, but I think that explaining and posting that entire method would be a waste of your time. However, I suspect it might be caused by a rapid, massive allocation of memory.
It definitely says Terminated due to memory error, not memory pressure.
I would like to know what is message really means. Also, is there any way to debug this message? No crash report is generated.
I am using ARC and iOS 7.
I was getting this error and could not understand what was wrong.
After some searching I found out that i forgot to disable zombies.
To disable do the following:
I was faced the same issue.("Terminated due to Memory Error")
I had tried the above all answers but nothing work for me. Then i debug my code and found a for loop is running for infinity time with allocating memory to a array with nil value every time.its use 300+MB so it give this error
Thanks.
I had exactly same issue. I thought it caused my program had memory leak or using too much memory. I use instruments and used allocating profile and program works fine. Also I ran program by device long enough, and it also works fine.
I also using iPad 3rd Gen for debugging, it might be causing because of that slow of the device or bug, it it seems like just Xcode and running from Xcode problem. Not the problem of memory leak or allocation.
If you make sure with instruments and running app on device itself and work
I was using Tesseract for OCR and when my target text got scanned, a GIF was supposed to play. When the GIF started to play, there was a memory spike, from 70-80MB to 450MB. The problem was that GIF was taking too much memory, the app would crash and Xcode would show that message. So I removed the concerned imageView from the superview of the ViewController.
imageView.removeFromSuperview
After this, the app would still spike to 450MB but then immediately release and come down to 40MB
Restart device worked for me. “Terminated due to memory error” message stopped to appear.
Edit the scheme, under Diagnostics you'll find several options to guard allocations. Refer to the documentation for details.
Question is: does it really say "terminated due to memory error" and not "pressure"? Check in instruments if your app is running low on memory, if the app does seem to run low on memory then that's what you should focus on regardless what the exact message is.
I got this error because I was adding full size photos to a collectionView cell sized 40x40. Read the 2 comments under the question from #matt. I had to scale down the images before adding them to the cell.
I had similar issue in Xcode 11.3 wherein camera was getting calling every-time we press on try again button. If these is done multiple times then crash happens.
This was fixed when we disabled Zombie objects. Below are steps:
Tap on project name present in top left. This will show list of targets present in project.
Tap on Edit scheme
Select Run option -> Diagnostics -> Uncheck Zombie Objects.
Now, run your project. It should work fine.
With Xcode 11 it started my project in Debug mode. I am doing some image recording/editing/returning to the user and that is not something you can use in Debug. Once I turned to Release mode, all went well.
I've faced this kind of issue due to inattentiveness.
I've been calling a function, which adds imageView as subview in:
override func layoutSubviews() {
super.layoutSubviews()
}
This caused a huge memory usage, so be attentive to this sort of things!
The thing that I noticed is that when I run my app on the device through cable and leave it idle for a long time I will also get that error.
Apple do address this and it just might be that it feels like the app is idle and just kills it.
In my case it was a corrupted Image from the API which raised my memory from 100MB to 4.5 GB due to processing size it took to display on screen!
An infinite loop was the cause of the memory leak for me. I could see the memory in Xcode rising to 1,6 Gb at which point the app crashed. The app's memory usage should be in mb and not gb and it should be relativly stable. If it rises quickly, say 100 mb a second, there's definitely something wrong. If none of the suggestions above have worked, you should 1. check the memory usage of the app, and 2. if the usage is too high, look for loops you've recently added.

cocos2d: my APP crashes but XCode doesn't give me any crash report

It used to work fine but now I get this message when loading a certain scene and then the APP crashes.
2012-12-01 18:33:55.104 AppName[9561:707] cocos2d: CCSpriteFrameCache: Trying to use file 'art1-hd.png' as texture
I have no idea on where to start debugging this. Is there a way to get a more precise error message to understand why this happens?
Btw, I have changed my code signing identity to developer and XCode doesn't yet give me any trace of it on the console other than the plain message above. I checked as well the device logs on the Xcode-Organizer section but no trace.
I whish there was something like in Java + Eclipse, where I could get a precise STACKTRACE of where the crash happened.
Any suggestion on how to get a precise stacktrace (E.g. with function name generating the crash)?
PS: I have set strip debug symbols to "NO" in DEBUG, and to "YES" in Release, but I am builing on my own test iPod and hence I think it is automatically build for "Debug" (the section says build for running and testing which is confusing as the project settings allows only debug and release). But I think the problem is not here.. but in the issues above before the PS:
EDIT: If I look into the debug navigator I don't see any stacktrace of methods, as I want, but just threads.. I need to figure out how to use the global exceptions.
I have no idea on where to start debugging this.
You have the cocos2d source code. I would start there.
Search for "trying to use file" in CCSpriteFrameCache to understand what the cause of this message is (which I agree is confusing, why shouldn't you use that file?).
As for the stack trace, it's available as soon as you add a global exception breakpoint. If the breakpoint triggers in OpenAL code make sure to set it to catch only Objective-C exceptions.

Find out what line app crashes on?

Is there an easy way to find out what line an app crashes on? The console gives little or no help to help me track down this bug and I would just like to know which line it crashes on.
Thanks!
The easiest way is to run the app under the debugger. When it crashes the debugger will show you what line of code crashed.
If you are throwing an exception rather than actually crashing, you can put a breakpoint on objc_exception_throw using the gdb console window - "br objc_exception_throw".
Are you using xcode? It should give you a visual representation of where you are in the code.
Please post the error you are receiving. The first thing to try is adding some breakpoints. For bad access errors, you can also get a more pin-point analysis from the compiler if you use NSZombie.

about .dSYM and GDB

I encountered a crash in my app. It's not 100% reproduce rate crash. From the crash log and dSYM, I can get the point where the crash happened in the line of some cpp file. But most of time the app run well. So I don't know what cause it crash. Can I got more infos in the line of cpp where it crash,like some value of varible in this line when the app crash and so on. Any suggestion is welcomed. Thanks!
Your crash log should have information about the state of the registers in it and that can be quite useful. Beyond that, though, you can't recover state of the running app from just the crash report.
Sporadic bugs such as this can be the most difficult to hunt down.
First of all I suggest taking a close look at the code? e.g. Is there a de-referencing of a pointer on this line. Does your crash log indicate that the error occurred before or after the tread returned to the run loop? Can you surround this crash line with an exception and log the state in the catch block?
It will help if you post the code which causes the crash!

Resources