EXC_BAD_ACCESS in main on iPad only - ios

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.

Related

SIGPIPE 13 with ASyncUDPsocket

I'm using an NTP framework in my App and it makes use of ASyncUDPsocket, however this framework makes the App break after coming back from the background after a while.
NetworkClock source: https://code.google.com/p/ios-ntp/issues/attachmentText?id=8&aid=6136447331175276042&name=NetworkClock.m&token=ky6UNYWjqChe2rQkEv1a_VSDpqk%3A1372342874389
AsyncUdpSocket source: http://pastebin.com/tuKqpnqZ
Breakpoints are:
[self doSend:[self socketForPacket:theCurrentSend]];
And:
result = sendto(theNativeSocket, buf, (size_t)bufSize, 0, dst, (socklen_t)dstSize);
I tried suggestions here:
https://code.google.com/p/ios-ntp/issues/detail?id=8
But so far the app stills crashes with a iPhone backboardd[28] <Warning>: Application 'UIKitApplication:nl.app[0x8f48]' exited abnormally with signal 13: Broken pipe: 13 error.
How can I prevent this?

How to debug iOS assert failure crash when it leaves no stack

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

RedPark unable to read Data from Serial port: UIViewController vs. UINavigationController

I am using the Redpark Serial SDK 1.4 r270 to help with i/o features for the iphone. One of the issues, that I am currently having is reading the data given using
- (void) readBytesAvailable:(UInt32)numBytes {
Here are my errors.
Feb 8 15:27:50 iapd[897] <Warning>: ERROR - /SourceCache/iapd/iapd-1065.23/iapd/IAPSession.mm:-[IAPSessionBasic _sessionBufferToAppHasSpaceAvailable] - 823 session=0x1 for connectionID=0x1e12ea00 failed to write bytes, errno = 32
Feb 8 15:27:50 iOS[7428] <Warning>: ERROR - /SourceCache/ExternalAccessory/ExternalAccessory-213/EASession.m:-[EASession dealloc] - 137 unable to close session for _accessory=0x20047eb0 and sessionID=65536
Feb 8 15:27:50 iOS[7428] <Warning>: ERROR - /SourceCache/ExternalAccessory/ExternalAccessory-213/EAOutputStream.m:-[EAOutputStream write:maxLength:] - 212 failed to write 229 bytes (wrote -1) with error 9
Feb 8 15:27:50 iOS[7428] <Warning>: ERROR - /SourceCache/ExternalAccessory/ExternalAccessory-213/EAInputStream.m:-[EAInputStream _readInputFromAccThread] - 357 error waiting for read data, errno = 9
This works perfectly works fine with a single view application.
Suppose there is a UINavigationController with view A and view B where A => B when a button is clicked. View B is using the RscMgr thread where all the magic happens to read from the serial port.
At the first instance of the UINavigationController at view B, it works perfectly fine if we stay on this view. We are able to disconnect, connect the port and we will continue streaming the data.
However, if I go back to view A then back to view B. Everything goes to hell. I cannot read the data anymore from this function, and I found (MULTIPLE) errors in the console. Does anyone have a good reason as to why this happened and how we can fix it? I know we have popped the UIViewController off the stack and everything resets and the RscMgr thread is created again but nothing is being viewed. I am unsure on how to clear the buffer using the SDK since it is not provided.
This is simpler than the solution above. Define your function in a different .m file, and have this launch from AppDelegate, not the ViewController.
I had this issue with former apps I wrote. The other option is to declare RscMgr in App Delegate, but then have it initialized in the given ViewController.
The scope you've declared
- (void) readBytesAvailable:(UInt32)numBytes {
in is likely the problem. I would declare this somewhere that does not go away when you open and close B. Such as on the UINavigationController, or on your AppDelegate.
Better yet, create a new singleton class that manages the interface to RedPark, and query it from the rest of your app as needed.

adsheet warning

can anyone explain the meaning/reason of this adsheet warning please?
Nov 23 09:24:06 unknown AdSheet[256] <Warning>: AdSheet running for 59.992 seconds with 1 clients and 1 assertions [banner:1]: info.company.app (State: Foreground Running) (Background: 0, no timer) has 1 banners: 0xee74b00:EDFD972C-2C31-45A6-A57C-F129F8D0CB97 (created 2011-11-23 17:23:44 +0000) [Visible: never] [In Window: YES]
it repeats every 20 seconds (in the log) and increments the "running for xx.xx seconds" with 20 seconds each time.
It comes up in the log with my iAd supported application and regardless whether the Test Advertisement is loaded or not.
after I kill the application it continues two or three times with:
Nov 23 09:33:06 unknown AdSheet[256] <Warning>: AdSheet running for 599.993 seconds with 0 clients and 0 assertions []:
and then it stops
thank you
I'm pretty sure the [Visible: never] has to do with the warning. Are you sure your AdSheet is visible and entirely on the screen? Did you by any chance accidently add a copy of the AdSheet to your viewController in IB that you don't know of? You should keep in mind that Ads should appear in the foreground.

ipad app crashes on new iOS 4.1.2 but works on 3.2

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

Resources