Xcode: debug unexpected iOS app crashes - iphone

I'm facing unexpected crashes of my app running on an iPhone 4 with iOS 5.0.1, the app crash without generating any error message nor crash log. I did also enabled zombies and tested with Instruments with no luck... how can I figure out where is the problem? I'm totally stuck :(
ps. I'm using ARC and my app is multi thread (NSOpertations + GCD)

(By popular demand:) There are some hints for catching the failure in this thread.

From the breakpoint-menu in Xcode, press the little '+' button at your window bottom left, and add an exception breakpoint. It will give you a heads up if the app throws an exception due to erroneous code.

Just follow this url you will get trick to track the causes of crash.

add some breakpoint before crashing point and add a lot of NSAssert to check your assertion.

Related

ARKit crashing in iOS 11.3

Since iOS11.3 I'm getting a significant number of new crash reports from my AR measurement app.
The crash description says:
Exception Type: SIGABRT
Exception Codes: #0 at 0x181b112ec
Crashed Thread: 0
Application Specific Information: *** Terminating app due to uncaught exception 'std::invalid_argument', reason: 'extrinsicTransform must have determinant 1.'
The crash is triggered by this line in my code, which is called on didUpdateFrame
NSArray<ARHitTestResult *> *resultArray = [_arsnView hitTest:position types:ARHitTestResultTypeExistingPlaneUsingExtent | ARHitTestResultTypeEstimatedHorizontalPlane];
According to the crash reporting, it happens to about 10% of the sessions (!!!!). Before iOS11.3, I had <0.1% crashes.
I tried feeding the hitTest with different values for position, including NaN etc, but I'm not able to reproduce the crash.
Any ideas?
Thanks!!
UPDATE 1
I checked that the currentFrame is still valid when calling the hitTest. Despite checking this with if(_arsnView.session.currentFrame), the app still shows the same crash :(
Thanks for your help. I found that checking the trackingState before performing the hitTest, resolves the crash. So basically, I'm checking:
if (_arsnView.session.currentFrame.camera.trackingState!=ARTrackingStateNormal)
{
// do not perform hitTest
}
else
{
// perform hitTest
}
In this example, _arsnView is a property from class ARSCNView
Anyone log a bug for this for 11.3? Getting the same effect trying to test an application with 11.3 on an iPhone X
My apologies for the earlier one, last night I was too sleep deprived.
Anyway, I raised a TSI for Apple, and they came back with the following.
Thank you for contacting Apple Developer Technical Support (DTS).
This a known issue when you perform a hit test and the ARCamera’s tracking state is either .notAvailable or .limited.
<https://developer.apple.com/documentation/arkit/arcamera.trackingstate>
The workaround is simply to not hit test when in either of those tracking states. This is also a best practice.
I hope this information suffices to address your concern to your satisfaction.

How to find memory leaks if they cause the app to crash?

I used Leak Instruments to find Leaks and set NSZombieEnabled to YES. When I press a button or a particular row from tableView my app crashes and I am unable to find any information in Instruments.
I followed the tutorial here:
http://www.raywenderlich.com/2696/instruments-tutorial-for-ios-how-to-debug-memory-leaks
How can I identify or get more information in Instruments when my app is crashing?
Use Zombie for finding out the Zombie message. It will show you Pink flag with message.
You can Use Zombie message by enabling from edit schema and in Run tab Checkmark Enable Zombie object and you can see released object from console
Zombies are not the only thing you can have there.
The only way to find leaks is to you profiler with "Leaks" component.
Try also running Project / Analyze for static analyze of your code about memory management errors.
For crash - I think you just have error in code - not really leak. Enable exception breakpoint in your xcode to catch a problem !
http://blog.manbolo.com/2012/01/23/xcode-tips-1-break-on-exceptions

iOS 7 migration help - Runs in Simulator, but not on device -- app does not load

Disclaimer: I'm helping out on another developer's code (he didn't have the time and the customer wants it fixed quickly) and so I'm not totally familiar with this code.
So the app is built for iOS 6, is in the App Store, and runs great. Until you try opening it on a device running iOS 7 GM. You see the splash-screen for a moment, then it crashes completely. This is causing problems because none of our users can use the app anymore after updating.
I just got the source code and I have been trying to figure it out. It compiles fine, and even runs in the iOS 7 simulator. (Although, of course, the UI needs to be redesigned for iOS 7.)
Here's where it gets weird: when I run it on my iPhone 5 (iOS 7) from Xcode, the app hangs (just like with the App Store version, of course) -- but it's just so weird, considering that in runs in the Simulator.
Good news is that I have some runtime errors that might help to track down the problem. I ran a search that indicates it could be a missing connection in a xib file, but I didn't find one.
Here is the log. If it helps, I can also include the build warnings.
2013-09-20 20:16:55.455 myappname[2514:60b] * Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan nan]'
* First throw call stack:
(0x2e3d0e8b 0x386ca6c7 0x2e3d0dcd 0x307d5feb 0x307d5eef 0x307d5e7f 0x30b53517 0x30b6373b 0x30c042f1 0x30b56533 0x307ddf43 0x307d9767 0x30b6b411 0x30b67ed5 0x30be7501 0x30be71a1 0x30c03685 0x30bcf53d 0x30c034bf 0x30b55f3d 0x30b55d19 0x30b55609 0x2ed32143 0x30b55495 0x30b62153 0x30b61bd3 0x30c43e13 0x30c8398b 0x30c83961 0x30c82abf 0x30c82663 0x30c8256f 0x5c4d7 0x30bc7425 0x30bc6e6b 0x30bc14b9 0x30b5bbe7 0x30b5aedd 0x30bc0ca1 0x3303c76d 0x3303c357 0x2e39b77f 0x2e39b71b 0x2e399ee7 0x2e304541 0x2e304323 0x30bbff43 0x30bbb1e5 0x5b485 0x38bc3ab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
Thread 1: signal SIGABRT
I really have no idea what is going on.
Any help would be greatly appreciated :)
try to use preferredContentSize to define view size.

SIGABRT AND SIGTERM THREAD in all the programs

I use Xcode 4.2 and I get 90% of the time this message:
#autoreleasepool
{
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
Thread 1: Program received signal "SIGABRT"
When it works and quit iOS Simulator I get :
Thread!: program received signal SIGTERM
NOW ALL the programs (even simple tutorials with single sound button) that worked perfect before when I quit Simulator I get SIGTERM and when I try to run again I get SIGABRT.
I am getting paranoidddddddddd.
Error: unknown error code.
This generally means that another instance of this process was already running or is hung in the debugger.sharedlibrary apply-load-rules all
Current language: auto; currently objective-c
(gdb)
What am I supposed to do?
Some things for you to try that have helped me in the past (in this order):
Product > Clean
Uninstall/delete your apps from your devices manually.
In iOS Simulator, iOS Simulator > "Reset Content and Settings".
Delete everything in your "Derived Data" for the projects causing the problems. (Screenshot) In Organizer > Projects.
Quit xCode.
Restart your machine.
I've noticed that Derived Data causes the most problems when you make multiple projects with the same name, wether it's on purpose, or by accident.
Edit: More details..
The only time I've ever gotten SIGTERM is when you run a test on a "device" and then quit the app from the device before you hit stop in xCode, then try and launch it again on the device. If it was more of a SIGABRT problem, I always check my IBOutlets. SIGABRT happens every time you delete the code for an outlet, but don't delete the connection in IB. [xcode 4.2.1]
The previous app is still 'stuck' in the simulator. Try completely quitting the simulator, cleaning your project, then trying to build again.
Edit: A complete restart of your mac sounds like the next step. In my experience this error has always had to do with an issue with the simulator, rather than the code itself.
SIGABRT means that your program is throwing an exception. If you don't explicitly set a breakpoint to trigger when the exception is thrown, then Xcode shows you the SIGABRT in main, which is useless for debugging.
You need to add an exception breakpoint so you can see where the exception is being thrown.

iphone app only works first time on simulator

I've got an issue with my iphone App and i'm not sure if its an xcode project issue or a code issue (I'm leaning towards xcode project issue at the moment).
If I reset the iphone simulator and build and run my app it works fine. If I then do a build and debug again the app will crash straight away with no meaningful callstack. The app will continue to crash until I remove it and start again. I didn't previously have this issue which makes me think i've just changed some project setting recently by mistake.
Has anyone had this before or can anyone think or a reason for this issue?
Are you saving/retrieving state? Without any other details, that's the first area I'd look into. Also try setting breakpoints and debug to pinpoint the problem.
paul_sns is correct, try setting breakpoint on your AppDelegate class and step-over. Probably you're retreaving a state that is incorrect. You could also activate the debugging console (run the application in debug mode) to see where it crashes (the callstack).
OK I've finally got to the bottom of it. I had quite a lot of memory overwriting going on (a sizing issue with a 2d array) and this was why it wasn't giving me any useful information when it crashed. Thanks for all the help - am glad I stumbled upon the problem before I pulled all my hair out!