'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: isfinite(coefficient)' crash - iphone

I get this crash report of which I cannot get the line in my code by symbolicating:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:
'Invalid parameter not satisfying: isfinite(coefficient)'
I searched my code for both function isfinite and variable coefficient and of course I found none. The crash was attributed to System 7.1.2 on iPhone6,1
What might have determined it?

I had the same issue and discovered it was an issue with auto layout not being able to satisfy constraints.
For me this was solved by removing proportional size constraints which couldn't be satisfied when their corresponding view was hidden.
If you need to keep the constraints, consider to lower their priority.

I had the same issue and similar to Timothy it turned out to be an auto layout constraint issue, but for a different reason. It took hours but I tracked it down to the CGRectInset() function appears to have a bug in the latest iOS 16.2. This app was working before iOS 16.2 and now it is getting this exception at startup, with no app changes in between. The exception now makes sense, the UI code is checking to see if a value isfinite and it is not, it's infinite.
In my case calling insetBy(dx: 5, dy: 0) (in Swift) caused the x and y fields to get infinite values when the original x/y are 0. I think this was a bug introduced in iOS 16.2. I'll file a bug report with Apple and see what they say.
My code was calling insetBy(dx: 5, dy: 0) and the result was +Inf. Doesn't make sense and documentation on that function doesn't mention this possibility.

Related

Why am I getting the error "EXC_BAD_ACCESS"

I am trying to debug my Autolayout using the suggestions of this website, to highlight views that are causing constraint issues. However when I try to change the color of the suspect view with the command
expr ((UIView *)0x7f9ea3d43410).backgroundColor = [UIColor redColor]
I get the Error
error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=1, address=0xcd4200020).
The process has been returned to the state before expression evaluation.
I have also gotten the error:
error: Execution was interrupted, reason: Attempted to dereference an invalid ObjC Object or send it an unrecognized selector.
The process has been returned to the state before expression evaluation.
I am not sure why I am getting this error as I have made sure to replace the example hex code with my own, what does this error even mean?
I am coding in swift, the website I reference uses objective-c, that may be my problem. what would the swift code be to do the same thing? I have tried:
expr ((UIView *)0x7f9ea3d43410).backgroundColor = UIColor.redColor
I think the short answer is "that link is from 2015 and the recommended technique uses hidden internal symbols that are no longer supported."
Specifically, the symbol is _autoLayoutTrace. That is a private symbol which apparently has been dropped.

How do I get more information about this exception?

I get the following error in XCode...
I've added a "Swift Error" breakpoint and left the "Type" box empty. I thought this might show some further info, but it doesn't appear to have any effect.
How can I find out where this error is arising from?
EXC_BAD_INSTRUCTION means that you have an invalid assertion (usually a force-unwrapped nil, though a bad cast could also be the culprit, here). Make sure that tourDto is a populated var, and that it can be cast to whatever toJSONString() returns (I'm not familiar with that method, and it could also be the culprit).

Lync 2013 Modality.ModalityStateChanged callback not always being called

So the issue I'm having only recently started after an update to the Lync client somewhere around version 15.0.4849.1000. The issue revolves around app sharing conferences, which I have working fine still in 2016 SFB and anything prior to 15.0.4849.1000.
The core issue as far as I can tell deals with Modality.BeginConnect, the passed in callback does not get called. Although, I have had it get called when I'm debugging, stepping through the code and hitting breakpoints, etc. So that leads me to think that normally maybe something's not getting initialized in time, or some sort of race condition, but I haven't been able to pin down exactly what makes it function correctly in that case.
EDIT: I just realized another exception occurs during the call to BeginConnect:
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Lync.Model.dll
Additional information: Exception from HRESULT: 0x80F10083
And that HRESULT translates to: "The operation is disabled by capability". What in the world does that mean?
The odd thing is (or seems odd to me) that even though the callback is never called, I do receive a ModalityStateChanged event for ModalityState.Connected...
So if you have any ideas what would perhaps cause that, please share!
I don't think these this is related, but a call to this:
m_aeConversationWnd = AutomationElement.FromHandle(m_ConversationWindow.Handle);
shortly before calling BeginConnect, fails with the exception:
A first chance exception of type 'System.ArgumentException' occurred in UIAutomationClientsideProviders.dll
Additional information: Value does not fall within the expected range.

can we prevent crash by using #try, catch mechanism .if the error is -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array

I am new to iPhone,
Our Team created an App and uploaded to "AppStore", We integrated "Bug Sense" also.
Now our app got negative reviews because of crash, We are tested our App in iPhone/iPad 6.1.3
In my bug sense we got this report like below:
1st Error:
-[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array [open]
2nd Error:
-[__NSArrayM objectAtIndex:]: index 61 beyond bounds for empty array [open]
Now IN my project i placed #try{ } catch blocks to the methods which uses "objectAtIndex" to prevent the crash,
and i placed the condition also i.e., if the array count is grater than "0" then only it will enter in to my condition which uses "objectAtIndex"
My question is, can we prevent the above errors crash by using #try, catch mechanism .
Thanks in Advance
No, you should not use #catch to recover from exceptions and continue execution as if nothing happened.
For two reasons:
First, you have a bug in your code. Using #catch to catch the exception and ignore it is not a fix. You are simply addressing a symptom, but the bug remains.
Secondly, exceptions for flow control -- exceptions for handling recoverable errors -- is explicitly not supported in iOS/Cocoa programming. If an exception is thrown through a call to the system, the behavior is undefined.
If you would like more details, see my answer here: Usage of NSException in iPhone Apps
In the Apple's Documentation, you have exactly this example:
[...] the case of an NSArray, for example, you should always check the
array’s count to determine the number of items before trying to access
an object at a given index. The objectAtIndex: method throws an
exception if you make an out-of-bounds request so that you can find
the bug in your code early in the development cycle—you should avoid
throwing exceptions in an app that you ship to users.
This wont break
if([array count]>n)
obj =[array objectAtIndex:n]
You may extend NSArray with a category providing one (or a number of similar) methods.
- (id) saveObjectAtIndex:(NSUInteger)n {
return (n < [self count]) ? [self objectAtIndex:n] : nil;
}
Or use a macro for that, which may be the better approach in terms of performance.
Frankly, I never did that myself. Why? If I did that then I had to check for nil and react on that accordingly. So in the end it is the same amount of work as checking for positive values (if the index variable is signed) and compare it with the count property and then react on the erroreous condition. Psycologically, doing it myself every time guides me writing quality code and supports my awareness for error tolerant coding.

Matlab: getting "Unexpected error status flag encountered. Resetting to proper state"

I have a matlab script, that every now and them produces the message:
Caught std::exception Exception message is:
bad allocation
Unexpected error status flag encountered. Resetting to proper state.
What could be causing this?
This is a bug in MATLAB, in which some part of MATLAB is not handling a std::bad_alloc exception correctly (std::bad_alloc is an out-of-memory exception thrown from the C++ runtime library).
The "Unexpected error status flag encountered. Resetting to proper state." is an internal diagnostic - you shouldn't see it unless MATLAB has gotten into a bad state, which in this case is happening because it's encountering the bad_alloc someplace where it was not expected. Recent versions of MATLAB have fixed most of these issues, except in extremely low-memory situations (like, there's less than 1 kilobyte of free memory left). What version are you using?
My best guess is that your script is trying to allocate some memory and failing. The occurrence of such an error will depend on the availability of memory on your computer at the time allocation is attempted. The available memory will vary according to what is going on at the time in other programs, the operating system, even the state of your Matlab session.
For a more accurate diagnosis, you'll have to tell us more, maybe even post your script.
It was happening to me, and it turned out I had too many files open. fclose('all') set everything back to normal, and I made sure that all my fopen were followed by fclose.