ios exception analyse NSInternalInconsistencyException - ios

My app crash with a NSInternalInconsistencyException like this
Exception reason:NSInternalInconsistencyException
Exception name:Can't cancel on a touch that isn't already active!
Exception stack:(
0 CoreFoundation 0x0000000191a4d1d0 <redacted> + 148
1 libobjc.A.dylib 0x000000019048455c objc_exception_throw + 56
2 CoreFoundation 0x0000000191a4d08c <redacted> + 0
3 Foundation 0x000000019250502c <redacted> + 112
4 UIKit 0x0000000197fd1960 <redacted> + 404
5 UIKit 0x0000000197fcf970 <redacted> + 1648
6 libdispatch.dylib 0x00000001908d61fc <redacted> + 24
7 libdispatch.dylib 0x00000001908d61bc <redacted> + 16
8 libdispatch.dylib 0x00000001908e43dc <redacted> + 928
9 libdispatch.dylib 0x00000001908d99a4 <redacted> + 652
10 libdispatch.dylib 0x00000001908e634c <redacted> + 572
11 libdispatch.dylib 0x00000001908e60ac <redacted> + 124
12 libsystem_pthread.dylib 0x0000000190adf2a0 _pthread_wqthread + 1288
13 libsystem_pthread.dylib 0x0000000190aded8c start_wqthread + 4
)
How do i analyse the log? Like What do those number tags mean,"+ 148" "+ 56"...? How to detect the code that have invoked this exception.

Is this a crash from a release build of the app, or do you have it in Xcode? If in Xcode please provide the code causing the crash?
Looking at your report, the line
Can't cancel on a touch that isn't already active!
seems very telling. I would look through your code for anywhere you are interacting with a UITouch object, or perhaps a UIGestureRecognizer. My guess would be that somewhere you are manually calling to cancel an interaction that you should not be, and there is a race condition where that can sometimes happen after the system has already cancelled the touch (or vice versa, I guess).

Related

iOS9 'modifying the autolayout engine from a background thread' without using autolayout

I started getting this warning :
This application is modifying the autolayout engine from a background
thread, which can lead to engine corruption and weird crashes. This
will cause an exception in a future release.
Here is the backtrace with the warning message :
Stack:(
0 CoreFoundation 0x25542303 <redacted> + 150
1 libobjc.A.dylib 0x24d0edff objc_exception_throw + 38
2 CoreFoundation 0x25542231 <redacted> + 0
3 Foundation 0x25e25bbb <redacted> + 170
4 Foundation 0x25ccb637 <redacted> + 38
5 UIKit 0x297e0431 <redacted> + 52
6 UIKit 0x297e0e1f <redacted> + 222
7 UIKit 0x297fd52d <redacted> + 96
8 UIKit 0x29efe579 <redacted> + 320
9 UIKit 0x299dc8e9 <redacted> + 148
10 UIKit 0x299cb44f <redacted> + 42
11 UIKit 0x296d5a83 <redacted> + 714
12 QuartzCore 0x277b1ad5 <redacted> + 128
13 QuartzCore 0x277ad1d1 <redacted> + 352
14 QuartzCore 0x277ad061 <redacted> + 16
15 QuartzCore 0x277ac581 <redacted> + 368
16 QuartzCore 0x277ac233 <redacted> + 614
17 QuartzCore 0x277d9b63 <redacted> + 310
18 libsystem_pthread.dylib 0x25279905 <redacted> + 508
19 libsystem_pthread.dylib 0x25279507 <redacted> + 86
20 libsystem_pthread.dylib 0x2527a485 pthread_exit + 28
21 Foundation 0x25ca31d7 <redacted> + 10
22 Foundation 0x25d5e34f <redacted> + 1178
23 libsystem_pthread.dylib 0x2527ac7f <redacted> + 138
24 libsystem_pthread.dylib 0x2527abf3 _pthread_start + 110
25 libsystem_pthread.dylib 0x25278a08 thread_start + 8
As far as i know i don't use Autolayout (as i want the app to be iOS 5.1.1 compatible). and also i don't seem to be within the reported backtrace.
I also have the PSPDFUIKitMainThreadGuard class enabled, which should be checking the main thread accesses but nothing trigered out of this thing.
Is there any way how to find out what is doing such a thing?
Question This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes doesn't explain how to debug such thing.
Whether or not you are using Autolayout directly is not the issue at hand. The OS is converting legacy autoresizingMask to modern NSLayoutConstraint under the hood.
The issue has to do with modifying the UI from anywhere but the main tread.
This typically happens when:
responding to a NSNotification
returning from an async method
executing a completion block on a thread you do not control
explicitly scheduling a task in the background
Note about The app doesn't crash...
The app will crash. All you need is time and a few thousand users...

NSInternalInconsistencyException with Parse

I have an application setup using Parse. Recently, I started getting the following error when my app starts up.
[Error]: Caught "NSInternalInconsistencyException" with reason "Tried to save an object with a new, unsaved child."
The app doesn't crash, as the exception is caught. However, I am unable to discern the cause of the exception. Below is the stack trace that is printed to the console:
(
0 CoreFoundation 0x0000000185f802f4 <redacted> + 160
1 libobjc.A.dylib 0x0000000197c4c0e4 objc_exception_throw + 60
2 CoreFoundation 0x0000000185f80218 <redacted> + 0
3 STSI 0x0000000100305e4c -[PFPointerObjectEncoder encodeParseObject:] + 116
4 STSI 0x000000010030528c -[PFEncoder encodeObject:] + 148
5 STSI 0x00000001002d0254 __129+[PFRESTQueryCommand findCommandParametersWithOrder:conditions:selectedKeys:includedKeys:limit:skip:extraOptions:tracingEnabled:]_block_invoke97 + 1752
6 CoreFoundation 0x0000000185ed47a4 <redacted> + 88
7 CoreFoundation 0x0000000185ec1cec <redacted> + 240
8 STSI 0x00000001002cfa9c +[PFRESTQueryCommand findCommandParametersWithOrder:conditions:selectedKeys:includedKeys:limit:skip:extraOptions:tracingEnabled:] + 936
9 STSI 0x00000001002cf69c +[PFRESTQueryCommand findCommandParametersForQueryState:] + 348
10 STSI 0x00000001002cf074 +[PFRESTQueryCommand findCommandForQueryState:withSessionToken:] + 84
11 STSI 0x00000001002dccdc __78-[PFQueryController findObjectsAsyncForQueryState:withCancellationToken:user:]_block_invoke + 116
12 STSI 0x000000010034f9ec __55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_2 + 96
13 libdispatch.dylib 0x0000000100c38fd4 _dispatch_call_block_and_release + 24
14 libdispatch.dylib 0x0000000100c38f94 _dispatch_client_callout + 16
15 libdispatch.dylib 0x0000000100c46b54 _dispatch_root_queue_drain + 2180
16 libdispatch.dylib 0x0000000100c48248 _dispatch_worker_thread3 + 132
17 libsystem_pthread.dylib 0x00000001984a922c _pthread_wqthread + 816
18 libsystem_pthread.dylib 0x00000001984a8ef0 start_wqthread + 4
).
I'm quite clueless as to what this stack trace is implying. Additionally, in the debugger, I can see many stacks of BFTasks being allocated.
What is the reason behind the exception being raised?

Sources of 'removeObjectAtIndex:'

I have a crash in
-[__NSArrayM removeObjectAtIndex:] + 262
However my code does not use removeObjectAtIndex:. Are there any other functions which might call removeObjectAtIndex: internally?
My guess is replaceObjectAtIndex: which I use.
Also, is there some documentation source where I can get information like this?
here is the complete stack trace:
Thread : Fatal Exception: NSRangeException
0 CoreFoundation 0x00000001860fe59c __exceptionPreprocess + 132
1 libobjc.A.dylib 0x000000019685c0e4 objc_exception_throw + 60
2 CoreFoundation 0x0000000185fe362c -[__NSArrayM removeObjectAtIndex:]
3 Musixmatch 0x0000000100b9da24 +[MyController updateMessage:] + 1011504
4 Musixmatch 0x0000000100b95dc8 -[MyAPICalls sendNewMessage:] + 979668
5 libdispatch.dylib 0x0000000196ea13ac _dispatch_call_block_and_release + 24
6 libdispatch.dylib 0x0000000196ea136c _dispatch_client_callout + 16
7 libdispatch.dylib 0x0000000196eab4c0 _dispatch_queue_drain + 1216
8 libdispatch.dylib 0x0000000196ea4474 _dispatch_queue_invoke + 132
9 libdispatch.dylib 0x0000000196ead224 _dispatch_root_queue_drain + 664
10 libdispatch.dylib 0x0000000196eae75c _dispatch_worker_thread3 + 108
11 libsystem_pthread.dylib 0x000000019707d2e4 _pthread_wqthread + 816
12 libsystem_pthread.dylib 0x000000019707cfa8 start_wqthread + 4
So the last method called from the app is updateMessage:. Update message itself only has a objectAtIndex:. It then makes a call to two methods in other classes. But if they were causing the crash, I believe they should have been included in the stack trace.

[UIThreadSafeNode createPeripheral]: unrecognized selector sent to instance

I tried to search about createPeripheral and i had no luck finding any information about it. Is there anyone here who had the same crash as this?
[UIThreadSafeNode createPeripheral]: unrecognized selector sent to instance
Which class does createPeripheral belong to?
How do you handle this crash?
note: there's not much information in the crash log
stackTrace =
(
0 CoreFoundation 0x31dcd2bb <redacted> + 186
1 libobjc.A.dylib 0x39a7297f objc_exception_throw + 30
2 CoreFoundation 0x31dd0e07 <redacted> + 170
3 CoreFoundation 0x31dcf531 <redacted> + 392
4 CoreFoundation 0x31d26f68 _CF_forwarding_prep_0 + 24
5 UIKit 0x33d4bf99 <redacted> + 52
6 UIKit 0x33bda80f <redacted> + 38
7 UIKit 0x33bda431 <redacted> + 404
8 UIKit 0x33f1ad19 <redacted> + 236
9 libdispatch.dylib 0x39e98621 <redacted> + 80
9 libdispatch.dylib 0x39e98621 <redacted> + 80
10 libdispatch.dylib 0x39e894b7 <redacted> + 22
11 libdispatch.dylib 0x39e8adcb <redacted> + 226
12 CoreFoundation 0x31da0f3b <redacted> + 1290
13 CoreFoundation 0x31d13ebd CFRunLoopRunSpecific + 356
14 CoreFoundation 0x31d13d49 CFRunLoopRunInMode + 104
15 GraphicsServices 0x358d72eb GSEventRunModal + 74
16 UIKit 0x33c29301 UIApplicationMain + 1120
...
);
Apologies for adding to an old post, but I do have a strong reproduction case for this bug. Open any software keyboard on the iPhone6+ (or iPhone6+ simulator) in a WebView. Put something in the paste-buffer, then click the paste button.
I haven't solved it yet, but I thought this might help if anyone is lost in google for this bug.
I've just got a similar crash report.
There is UIWebBrowserView in the call stack. Maybe it is a bug in it.
Our application uses UIWebView to show a simple html page, and I receive random crashes in WebView regulary. I have no idea what to do with it.
In my case this error occured when I tried to customize -inputaccessoryview on contenteditable div.
I believe createPeripheral has something to deal with Keyboard display as
webView.keyboardDisplayRequiresUserAction = NO;
solved this crash for me.

Interpreting iOS crash reports

I'm experiencing multiple crashes where it appears that a native iOS method is calling functions from a third-party library. Here's an example:
Thread: Unknown Name (Crashed)
0 libsystem_kernel.dylib 0x33222350 __pthread_kill + 8 + 8
1 libsystem_c.dylib 0x3500f973 abort + 95 + 94
2 libsystem_c.dylib 0x34ff04d1 basename + 1
3 FireChat 0x00036489 -[OTOverlayButton drawRect:] + 1
4 Foundation 0x37a4a5a9 -[NSDictionary(NSKeyValueCoding) valueForKey:] + 33 + 32
5 FireChat 0x709d -[NetworkModel getUserForUid:] (NetworkModel.m:150)
6 FireChat 0x0001c42f -[OpenTokController session:didReceiveStream:] (OpenTokController.m:258)
7 libdispatch.dylib 0x32da011f _dispatch_call_block_and_release + 11 + 10
8 libdispatch.dylib 0x32d9f4b7 _dispatch_client_callout + 23 + 22
9 libdispatch.dylib 0x32da41bd _dispatch_main_queue_callback_4CF$VARIANT$mp + 225 + 224
10 CoreFoundation 0x37dbbf3b __CFRunLoopRun + 1291 + 1290
11 CoreFoundation 0x37d2eebd CFRunLoopRunSpecific + 357 + 356
12 CoreFoundation 0x37d2ed49 CFRunLoopRunInMode + 105 + 104
13 GraphicsServices 0x358e22eb GSEventRunModal + 75 + 74
14 UIKit 0x3a1b42f9 UIApplicationMain + 1121 + 1120
15 FireChat 0x43b3 main (main.m:8)
To me, it appears that the [NSDictionary valueForKey:] method is invoking [OTOverlayButton drawRect:] which comes from a third-party library. This shouldn't be possible -- am I reading the crash report wrong?
[OTOverlayButton drawRect:] isn't called anywhere in my code. Note that the dictionary contains (my) objects which contain pointers to objects from the third-party library.
The library vendor and I are both baffled.
Thanks.
I believe the cause of this crash was memory corruption resulting from calling performSelector: on a method that returned a struct. See this blog post for more details:
Why performSelector is more dangerous than I thought

Resources