I am trying to debug what appears to be an assertion failure on iOS. The device in question seems to produce no crash logs. Instead, in the console, I see this:
Apr 11 16:22:56 iPhone5 SpringBoard[69] <Warning>: Killing com.yourapp for termination assertion
Apr 11 16:22:56 iPhone5 com.apple.launchd[1] (UIKitApplication:com.appspot.scruffapp[0xa993][19484]) <Notice>: (UIKitApplication:com.yourapp[0xa993]) Exited: Killed: 9
Is there any way to connect this very limited information to an actual source file + line number? Also, why might the device not be creating any crash logs, which are obviously much easier to symbolicate and diagnose?
Thanks,
Eric
Have you tried using:
#try {
//code here
}
#catch (NSError *error) {
NSLog(#"%#", error);
}
Related
When I test my app on my iPad I can consistently and reliably get it to crash. When it does, I get an EXC_BAD_ACCESS error in main, and the root cause is far from obvious. I have tried the following steps to try to shed more light on it:
I have enabled zombies. This doesn't seem to have had any affect at all in the output, which makes me think this is not a zombie issue (but clearly I could be wrong).
I have add an exception breakpoint, but when the app crashes, the exception breakpoint doesn't kick in, and all I get is the standard green arrow next to line 16 of main.
I have run the Analyzer and corrected the few minor error that were revealed there. Still, no effect.
I have confirmed that the same problem is occurring for two of my testers who receive the build via test flight.
I have performed a 'Clean' as well as a 'Clean Build Folder'
Here is whats especially weird. When I test on the iPad the app crashes consistently. When I test in a simulator it will not crash no matter what I do. So if it IS a zombie I am at a loss as to how to discover which object need retained better. Further, if I test on my iPhone, the app also does not crash.
Where the crash occurs: In the app, I have a number of sprite nodes that display information, when I touch one of them (actually, what I am touching is a child sprite made to look like a cancel button), what is supposed to happen is that I remove the cancel button's parent from its parent with:
[[self parent] removeFromParent];
Pic of call stack:
There is nothing in the console in the main xcode window, but this is in the console of the device (from the organizer window:
Apr 10 08:50:39 Roberts-iPad com.apple.debugserver-310.2[596] <Warning>: 69 +0.000164 sec [0254/060b]: far -> 788
Apr 10 08:50:39 Roberts-iPad com.apple.debugserver-310.2[596] <Warning>: 70 +0.000079 sec [0254/060b]: esr -> 796
Apr 10 08:50:39 Roberts-iPad com.apple.debugserver-310.2[596] <Warning>: 71 +0.000081 sec [0254/060b]: exception -> 800
Apr 10 08:50:42 Roberts-iPad backboardd[31] <Error>: HID: The 'Passive' connection 'Bubble Fit' access to protected services is denied.
Apr 10 08:50:43 Roberts-iPad backboardd[31] <Warning>: CoreAnimation: updates deferred for too long
Apr 10 08:50:57 Roberts-iPad lockdownd[25] <Notice>: 01cdc000 _select_socket: receive secure message timeout!
Apr 10 08:50:57 Roberts-iPad lockdownd[25] <Notice>: 01cdc000 _receive_message: walk away - non-SSL 1
Up until yesterday I thought I was very, very close to shipping :P I would appreciate any advice on how to shed more light on what the root cause of this exception is. Thanks!
UPDATE: As LearnCocos2D points out below, I may very well have the same SpriteKit bug he links to. The suggestion is to override removeFromParent. I tried this, but it produces an error:
- (void)removeFromParent
{
[self removeFromParent];
self = nil;
[super removeFromParent];
}
The error it produces is that self cannot be assigned to outside of init. How should I rewrite that?
As it turns out, this really was a bug in SpriteKit, further discussed here:
Sprite Kit iOS 7.1 crash on removeFromParent
My fix was to override removeFromParent, in the SKShapeNode subclass that contained the children that needed to be nil'ed before the parent was removed, as thus:
- (void)removeFromParent
{
[self.addButton removeFromParent];
[self.cancelButton removeFromParent];
self.addButton = nil;
self.cancelButton = nil;
[super removeFromParent];
}
The children shape nodes are properties of the parent.
Apple has approved our first app that has In-App Purchases - however suddenly when a user taps the "Upgrade" button the app hangs momentarily and then crashes. By using the Console feature in XCode's Organizer I was able to obtain the following report:
Sep 18 15:12:48 iPad MyApp[53107] <Error>: *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x316f92a3 0x3958497f 0x31643e8d 0x54b23 0x335ec0c5 0x335ec077 0x335ec055 0x335eb90b 0x335ebe01 0x335145f1 0x33501801 0x3350111b 0x351f35a3 0x351f31d3 0x316ce173 0x316ce117 0x316ccf99 0x3163febd 0x3163fd49 0x351f22eb 0x33555301 0x4b81f 0x399bbb20)
Sep 18 15:12:48 iPad ReportCrash[53109] <Notice>: Formulating crash report for process MyApp[53107]
Sep 18 15:12:48 iPad com.apple.launchd[1] (UIKitApplication:com.mycompany.MyApp[0x716c][53107]) <Warning>: (UIKitApplication:com.mycompany.MyApp[0x716c]) Job appears to have crashed: Abort trap: 6
Sep 18 15:12:48 iPad ReportCrash[53109] <Error>: libMobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary
Sep 18 15:12:48 iPad backboardd[26] <Warning>: Application 'UIKitApplication:com.mycompany.MyApp[0x716c]' exited abnormally with signal 6: Abort trap: 6
Sep 18 15:12:48 iPad ReportCrash[53109] <Notice>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/MyApp_2013-09-18-151248_iPad.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0
This does not occur when I run the app on my device, and it must've worked when Apple review it or else they would not have cleared it for sale.
My guess it that my products array is null and when trying to purchase _products[0] (the only available one) it crashes.
More Info:
I followed Ray Wenderlich's Tutorial when adding In-App Purchases:
[[AppStoreHelper sharedInstance] requestProductsWithCompletionHandler:^(BOOL success, NSArray *products) {
if (success) {
_products = products;
}
[refreshControl endRefreshing];
}];
To sum up: why does it only work in testing mode?
Thanks in advance!
It works now. I guess Apple's servers needed some time to process the purchase...
NSAssert works fine in Xcode 4 (up to 4.6 inclusive) when running debugger. Assertion fires, you breakpoint it, then it outputs the assertion message.
But when running outside the debugger (debug build on device), assertions fire - but with no message.
This makes assertions useless: you can see the line number which asserted, but the detailed message from the programmer has been wiped.
Is this an Xcode problem? A clang/LLVM problem? Is it a setting with the wrong value? Or is there a workaround?
Example code:
NSAssert(FALSE, #"X was invalid: %i", x );
Example output (console):
<Warning>: *** Assertion failure in -[myClass method:], myClass.m:124
<Notice>: Formulating crash report for process MyApp[82]
Expected output (console):
<Warning>: *** Assertion failure in -[myClass method:], myClass.m:124
<Warning>: *** "X was invalid: -435"
<Notice>: Formulating crash report for process MyApp[82]
NB: I'm only guessing how Apple would format the assertion message.
UPDATE: Found the problem. I was wrong with my original description:
The message was not being output to console while running in the debugger
Two observations:
The NSAssert is intended for debugging purposes only. When you build a release version of your app, NSAssert does nothing.
When you use NSAssert in a debug build of an app running on a device (not through the debugger), the message is in the device's console, not Xcode's. If you go to the "Organizer" in Xcode, choose "Devices", select your device and look at the "Console", you'll see your assertion there.
For example, I put in a line of code in a "Assertion Test" app:
NSAssert(FALSE, #"Assertion performed here");
When I look at the device's "Console" through Xcode's Organizer, I see:
Aug 6 09:10:53 Rob-iPod amfid[200] : Aug 6 09:10:53 SecTrustEvaluate [leaf CriticalExtensions IssuerCommonName]
Aug 6 09:10:53 Rob-iPod Assertion Test[199] : *** Assertion failure in -[ViewController viewDidLoad], /Users/rryan/Documents/Development/Xcode/Assertion Test/Assertion Test/ViewController.m:21
Aug 6 09:10:53 Rob-iPod kernel[0] : launchd[199] Builtin profile: container (sandbox)
Aug 6 09:10:53 Rob-iPod kernel[0] : launchd[199] Container: /private/var/mobile/Applications/7A7A62EF-8CEC-4388-932D-5C02DE77B841 (sandbox)
Aug 6 09:10:53 Rob-iPod Assertion Test[199] : *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Assertion performed here'
*** First throw call stack:
(0x315592a3 0x391d797f 0x3155915d 0x31e2eab7 0x843f7 0x33380595 0x333c0d79 0x333bcaed 0x333fe1e9 0x333c183f 0x333b984b 0x33361c39 0x333616cd 0x3336111b 0x350535a3 0x350531d3 0x3152e173 0x3152e117 0x3152cf99 0x3149febd 0x3149fd49 0x333b8485 0x333b5301 0x84149 0x3960eb20)
Aug 6 09:10:54 Rob-iPod ReportCrash[201] : Formulating crash report for process Assertion Test[199]
Aug 6 09:10:54 Rob-iPod com.apple.launchd[1] (UIKitApplication:com.robertmryan.Assertion-Test[0x7be0][199]) : (UIKitApplication:com.robertmryan.Assertion-Test[0x7be0]) Job appears to have crashed: Abort trap: 6
Aug 6 09:10:54 Rob-iPod backboardd[26] : Application 'UIKitApplication:com.robertmryan.Assertion-Test[0x7be0]' exited abnormally with signal 6: Abort trap: 6
Aug 6 09:10:54 Rob-iPod ReportCrash[201] : libMobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary
Aug 6 09:10:54 Rob-iPod ReportCrash[201] : Saved crashreport to /var/mobile/Library/Logs/CrashReporter/Assertion Test_2013-08-06-091053_Rob-iPod.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0
If you look at that fifth line, you'll see the assertion message there.
This is very situation specific ... I hadn't realised, but we had HockeyApp / QuincyKit embedded in the app.
Hockey appears to have a nasty bug where it:
captures NSAssertions
Allows them to crash
Deletes the message
Deletes the logging
... does not upload anything to the Hockey website
So ... the messages were visible in the debugger, but only in the debugger variables - I was a fool, and not paying attention: they weren't appearing in the console.
To be clear: some assertions sometimes appear in Hockey (looking at the Hockey console), but most assertions are silently missing. 100% of App crashes appear, but only about 10% of assertion crashes.
I have an app here that could be boiled down to uiscrollviews with images that you can flick through. I'm experiencing something really strange here though.
When flicking through each image (have roughly 60 of them in total), at some point the app just quits. I'm running it in XCode 4 (GM seed 2), and I'm getting no debug info, and no messages in the console at all. Turned on NSZombieEnabled, but that didn't change anything.
I'm not even getting a crash log on the device. I've run it through instruments, and it doesn't report any leaks, and my memory usage goes between 700 and 1100KB when run on the device.
I even checked each of my "pages" (the ones you flick through) and added messages at init and dealloc, and I can confirm that they're all getting deallocated properly (only keep the current and the pages on each side loaded).
Now, this seem to mostly happen at the same point in the app when I just start at the beginning and flick through each page going right, plus or minus a few pages, all pointing toward a memory issue, I do get a memory warning from the device, but there is absolutely nothing pointing to me using a lot of memory at all, nor that there are any leaks.
I got this from the console on the device when the app quits:
Mar 8 14:13:37 unknown configd[26] : jetsam: kernel memory event (92), free: 451, active: 2894, inactive: 2267, purgeable: 0, wired: 16709
Mar 8 14:13:37 unknown configd[26] : jetsam: kernel termination snapshot being created
Mar 8 14:13:37 unknown com.apple.launchd[1] : (com.apple.AOSNotification) Exited: Killed: 9
Mar 8 14:13:37 unknown com.apple.launchd[1] : (UIKitApplication:com.apple.mobilemail[0xc2ee]) Exited: Killed: 9
Mar 8 14:13:37 unknown com.apple.launchd[1] : (UIKitApplication:no.NRC.NRCMag[0x3c6c]) Exited: Killed: 9
Mar 8 14:13:37 unknown com.apple.launchd[1] : (com.apple.dataaccess.dataaccessd) Exited: Killed: 9
Mar 8 14:13:37 unknown SpringBoard[30] : Received memory warning. Level=1
Mar 8 14:13:37 unknown SpringBoard[30] : Application 'Perspective' exited abnormally with signal 9: Killed: 9
Mar 8 14:13:38 unknown SpringBoard[30] : Application 'Mail' exited abnormally with signal 9: Killed: 9
Mar 8 14:13:38 unknown SpringBoard[30] : Memory level is not normal (60%). Delaying auto-relaunch of 'Mail' for 30 seconds.
Mar 8 14:13:38 unknown SpringBoard[30] : Received memory warning. Level=2
Mar 8 14:13:38 unknown kernel[0] : launchd[1253] Builtin profile: dataaccessd (sandbox)
Mar 8 14:13:39 unknown AOSN[1252] : AOSNotification Daemon Starting...
Mar 8 14:13:39 unknown AOSN[1252] : Device Information. Name: Calypso, BuildVersion: 8F190, Product Type: iPad1,1, Unique Device ID: f02b304ed9a62109de1f3efd3e1e23158a76b2d4
Mar 8 14:13:40 unknown ReportCrash[1254] : Saved crashreport to /Library/Logs/CrashReporter/LowMemory-2011-03-08-141339.plist using uid: 0 gid: 0, synthetic_euid: 0 egid: 0
Mar 8 14:13:40 unknown SpringBoard[30] : Received memory warning. Level=1
Mar 8 14:13:40 unknown dataaccessd[1253] : DA|Registered for wake notification
Mar 8 14:13:40 unknown AOSN[1252] : Push: Loading...
Mar 8 14:13:41 unknown profiled[1257] : profiled|Service starting...
Mar 8 14:13:41 unknown dataaccessd[1253] : EAS|EAS Protocol Manager set to ASProtocolUnknown
Mar 8 14:13:41 unknown dataaccessd[1253] : CalDAV|A refresh fired, but we're still waiting on a gatekeeper lock
Mar 8 14:13:42 unknown dataaccessd[1253] : EAS|EAS Protocol Manager set to ASProtocol12_1
Now this mentions a crash report, but how do I get a hold of this when it doesn't show up in the Organizer in XCode? And why am I getting memory warnings when Instruments (and a thorough look at my code) says that I'm not using much memory, nor leaking?
Help!
EDIT: Got 3.2.6 up and running here and the console now gives me this:
Program received signal: “0”.
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Unknown error loading shared library "/Developer/usr/lib/libXcodeDebuggerSupport.dylib")
Okay, so I figured it out here, and it's a bit silly.
I use UIImage's imageNamed method to load each image/page, and apparently this was causing the memory warnings.
There's a couple of things that bother me a bit about this.
The caching is obviously a good thing, but apparently in 4.3 GM it doesn't seem to actually empty its cache when a memory warning occurs.
The memory usage building up isn't being reported as being used by my app.
I have a app in which i play a splash video and have added some custom fonts.
The app works fine on ipad 3.2 but on 4.2 etc it crashes. The log says that i release something that i dint alloc. I have checked my code a hundred times and i dont do any such thing.
Either ways it works on the simulator and on the device(both 3.2)
any ideas?
EDIT:
<Error>: df(7903,0x3e3d7898) malloc: *** error for object 0x1a11b0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Wed Jan 19 20:35:38 unknown UIKitApplication:com..imagazine[0x9c7c][7903] <Notice>: def(7903,0x3e3d7898) malloc: *** error for object 0x1a11b0: pointer being freed was not allocated
Wed Jan 19 20:35:38 unknown UIKitApplication:com.imagazine[0x9c7c][7903] <Notice>: *** set a breakpoint in malloc_error_break to debug
Wed Jan 19 20:35:39 unknown ReportCrash[7905] <Notice>: Formulating crash report for process df[7903]
Wed Jan 19 20:35:39 unknown com.apple.launchd[1] <Warning>: (UIKitApplication:com.imagazine[0x9c7c]) Job appears to have crashed: Abort trap
Wed Jan 19 20:35:39 unknown SpringBoard[27] <Warning>: Application 'df' exited abnormally with signal 6: Abort trap
Wed Jan 19 20:35:39 unknown ReportCrash[7905] <Error>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/df_2011-01-19-203538_Sumas-iPad.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0
SOLUTION:
First of all use the NSZombies and you will catch such errors.
The Problem: I had a timer setup for every 0.2sec and it was clearing a UIView and allocating it, not every 0.2secs but maybe once every 5secs.
I did a standard check:
if(vewCustom!= nil) {
[vewCustom removeFromSuperView];
[vewCustom release];
vewCustom = nil;
}
But the strange thing was i verified the code hundreds of times and I was not over releasing and either ways it worked on iOS4.2 for iPhone.
I removed the Timer but still it was crashing and then I removed the release and now it works fine.
Strange but it would be good if someone can explain what i was doing wrong.
You could try running the app in debug with zombies enabled. This way you'll get a stack trace on the overreleased object here's a link on how to set it up.
http://iosdevelopertips.com/debugging/tracking-down-exc_bad_access-errors-with-nszombieenabled.html
Assume that the log is true. The easiest way to find it is to enable Zombies and then exercise your application throughly. See here (tip #1):
http://loufranco.com/blog/files/debugging-memory-iphone.html
Another thing to do is a Build and Analyze and look at each thing it flags. In my experience there are very few false positives.
Just noticed this while looking for something else. The reason for the crash is that removeFromSuperview causes the superview to release the view. Thus, the release that follows is redundant (over-release). Won't be an issue with ARC, but could cause some confusion in other situations