NSInvalidArgumentException caused by "<null selector>" - iphone

we have an iPhone app in the app store where we see a lot of crashes after an update. These crashes did not occure when testing it before submiting it to the app store and we cannot reproduce the crash on our own devices.
Heres the crash message we get:
'NSInvalidArgumentException', reason: '*** -[MessageHeader ]:unrecognized selector sent to instance 0x4551450'
The source that causes this message is:
[self fireDelegateIfRegisteredMessageId:header.messageID andMessage:message];
The only place where MessageHeader is referenced is "header.messageID" but I am wondering how this selector would become nil. Also that same statement is used on various places above this line and it worked there.
What could cause this problem? Espacility what could cause an selector to become nil except the following code?
SEL selectorTest = nil;
[self performSelector:selectorTest]

I had a similar problem. My problem was a buffer overflow shortly before the line who caused the exception. It was some quick and dirt feature adding and forgot to check it thoroughly.
I used to write 16 Bytes in a 8 Bytes big buffer. The exception uccured only on device and not in simulator or debug builds. It was really an anoying bug.

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.

"unrecognized selector sent to instance" on every selector

i have a huge issue here
I'm developing an app and i was actually very close to have it done. I was testing it many times on many iPhones and after i fired Producy>Analyze it crashes everywhere!
Every UIButton, UIScrollView etc, everything that i tap, pan or swipe gives me an error of the unrecognized selector.
I tried both cleaning a project, and reboot devices (mac and iphone) but it didn't help. I also recovered recently edited .m file to the last version that worked well but errors still comes.
Does anyone have the idea of what happened and how can i get my project back to life?
I'm really frustrated, please help...
EDIT
2013-07-03 17:30:24.996 APPNAME[349:907] -[__NSCFData shootAgain:]: unrecognized selector sent to instance 0x1d1b8e00
2013-07-03 17:30:25.004 APPNAME[349:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFData shootAgain:]: unrecognized selector sent to instance 0x1d1b8e00'

iPhone - Debugging a crash when you can't find it

A crash was reported in my app, Crash Pad Drums.
It cites a problem with certain cymbal sounds causing a crash on an iPod 4. One problem. I can't find the crash on my iPod touch 2, and I don't have an iTouch 4.
What in the heck can I do about this?
On another note, my app is free for today. If someone could download it and find the circumstances of the crash, I'd be in your debt.
EDIT:
Clarification
I can't actually cause the crash as I don't have a newer device to test on. I suspect that it's an iOS 5 issue which I am looking into now, but in the future what should I do if I'm cheapo and not willing to buy a new iTouch?
EDIT:
Console log:
2011-10-14 23:08:25.797 Crash Pad[794:12203] -[NSConcreteValue doubleValue]: unrecognized selector sent to instance 0xec9e2e0
2011-10-14 23:08:25.798 Crash Pad[794:12203] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteValue doubleValue]: unrecognized selector sent to instance 0xec9e2e0'
*** First throw call stack:
(0x1c49052 0x21fdd0a 0x1c4aced 0x1baff00 0x1bafce2 0x16f4f0 0x15d99e 0x14e0d8 0x168d42 0x15ace2 0x5c28c7 0x5c2a31 0x5c2d45 0x1be0f4a 0x1bac665 0x1bac056 0x5c2c43 0x249c8 0x24a58 0x8a72 0x1c4aec9 0x67a299 0x67a306 0x1c4aec9 0x67a299 0x67a306 0x5b6a30 0x5b6c56 0x59d384 0x590aa9 0x28c3fa9 0x1c1d1c5 0x1b82022 0x1b8090a 0x1b7fdb4 0x1b7fccb 0x28c2879 0x28c293e 0x58ea9b 0x1f0d 0x1e85)
terminate called throwing an exceptionCurrent language: auto; currently objective-c
What you've found is an Apple bug. You can easily reproduce by animating any view, like this:
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:#"transform.scale"];
anim.duration = 0.2;
anim.repeatDuration = HUGE_VALF;
anim.autoreverses = YES;
anim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 0.0)];
[view.layer addAnimation:anim forKey:#"throb"]; // if this isn't nil we crash on tap
Run the project. Tap the throbbing view. Crash. This code was perfectly fine on iOS 3 and iOS 4. The workaround for now is to set forKey: to nil, but that may be unacceptable, as this argument can be important - a non-nil key means that if you later add another animation with the same key, this animation is removed, which might be exactly what you were trying to do.
I have submitted a bug report to Apple, and I suggest you do the same.
EDIT (2/3/12): Okay, Apple says this is my bug, not theirs. Since I'm supplying a transform, I need to use a key of #"transform", not #"transform.scale". Moreover, the z-value of my 3D scale transform should be 1, not 0.
Set NSZombieEnabled, MallocStackLogging, and guard malloc in the debugger. Then, when your App crashes, type this in the gdb console:
(gdb) info malloc-history 0x543216
Replace 0x543216 with the address of the object that caused the crash, and you will get a much more useful stack trace and it should help you pinpoint the exact line in your code that is causing the problem.
Do you have a crash log or two that you can post? That would be helpful.
Given that it is crashing on newer hardware as opposed to older, it is unlikely to be a memory related issue. Most likely, it is a timing issue related to threading; the faster device gets something done sooner and touches a data structure before something else is done with it. Given that sound playback is a constant duration across the different devices would lend further credence to this theory.
It ended up being an issue with iOS 5. I was able to narrow down the cause of the crash by commenting out various pieces of code. When in doubt, comment out.

Crazy MAPKit bug 'NSInvalidArgumentException', reason: '*** -[UISwipeGestureRecognizer removeFromSuperview]: unrecognized selector sent to instance

Ok, i have been buried in MAPKit for quite a while. I have dropping pins from a SQLite DB. Distance locations working, annotations working, looks great. Even my activity indicator works. Then right before I hand off the project, I'm swiping, gesturing, you name it to my cute map, works great, then BOOM! yipes!
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UISwipeGestureRecognizer removeFromSuperview]: unrecognized selector sent to instance 0x143cb0'
I'm creating this by code, no IB. Google turned up ZERO. Any tips on tackling this one appreciated! For some reason my mapView freaks out on a SwipeGesture? huh?
Exceptions of this type, particularly when they are mysterious in origin and involve objects you don't recognize, are usually due to memory management bugs -- overreleasing objects, keeping around pointers to objects w/o retaining them, etc. I'd try running with NSZombieEnabled to see if you can spot the source of the bug. (It is in general a good tool to have at your disposal.) A decent intro to NSZombieEnabled is:
http://www.fromconcentratesoftware.com/2007/08/09/nszombieenabled-for-the-debugger-adverse/

TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION error iPhone SDK development

I have a working program that was written by another programer that I am trying to add some features to in an effort to learn the iPhone SDK. I have carried out what I would assume was a fairly simple task of adding an additional UIButton to an existing view with like buttons. I have used the other UIButtons as a model and it seems this should be a simple task.
The problem is when the line that calls this subview is executed I get the rather vague error flag of TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION. Where do I find more information on this error code? I looks to me like a very general error and certianly there must be someplace in the Xcode shell that gives me more detail on what this means?
I have isolated the line where it occurs and it seems to happen on the first reference to the new view. Is it a problem with the connections made in interface builder? Any suggestions would be helpful as I really feel like I am grasping at straws at this point...
You want want to trap the exception when it happens, you might then be able to track it down in the debugger. A useful set of breakpoints to use when your debugging Cocoa apps are objc_exception_throw and -[NSException raise]. In the iPhone I think all exceptions travel through objc_exception_throw but if your were targetting Tiger or earlier you should set a breakpoint on both.
There are more debugging techniques at http://www.cocoadev.com/index.pl?DebuggingTechniques.
This is an exception generated by the Objective-C runtime. Hit CMD-SHIFT-R to bring up the debugger console. You'll see all the gdb startup information at the bottom of the window, but if you scroll up past the stack info, you'll get to something that should look like this:
[Session started at 2009-04-09 14:39:27 -0700.]
2009-04-09 14:39:31.246 LearnGLES[10415:20b] *** -[EAGLContext fakeMessage]: unrecognized selector sent to instance 0x528150
2009-04-09 14:39:31.248 LearnGLES[10415:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[EAGLContext fakeMessage]: unrecognized selector sent to instance 0x528150'
2009-04-09 14:39:31.250 LearnGLES[10415:20b] Stack: (
2517758219,
2486509115,
....
That's just a complete sample exception that I made up by changing code to send a non-existent message to an object, but there are a lot of possibilities as to what yours might be. Anything that would generate a run-time exception in any of the Objective-C frameworks could be the culprit (un-parseable dates to a date formatter, invalid messages to objects, etc...)
It probably means that you used some memory after deallocating it or used it without initializing it. Often when you look at the stack after this all you'll see is the part of the main loop that performs the autoreleases, which clearly isn't going to help you.
Really you need to get a good understanding of how memory management works in Objective-C and then take a look at your changes. There's not really a silver bullet here. The good news is that it gets easier with experience.
This is a nice article about debugging in Objective-C.
What connections have you made in interface builder? Are you making a call to any methods when the button is clicked? What is the method signature in that case? Have you made any changes to the original code, where you might have accidentally deleted some code which was important. It would help if you post some code. The exception is very generic.
I had a similar problem when I released things that I had not explicitly allocated.
In my case, I had a background image UIImage *image=[UIImage ...] and was setting it to be the background of my UIButton, and then did [image release];
You don't want to do the [image release]: the UIButton owns it now, and it will free it when no longer needed.
Maybe you have a similar issue?