ios13.6.1 'NSInternalInconsistencyException', reason: 'Unexpected sessionID mismatch'

When I sign in the use of Security framework, met a collapse, "Terminating app due to uncaught exception 'NSInternalInconsistencyException, reason:' Unexpected sessionID mismatch, '" because after see SecKeyRawSign function appeared problem, do you have any good solution? The current crash is the "Hardware Model: iPhone9,1
The iPhone Type: the iPhone 7"
Answered by DTS Engineer in 640981022

The crash report shows that a crash occurred when I called
SecKeyRawSign.

Can you post the full crash report? Use the paperclip button to add it as a text attachment so that it doesn’t clog up the timeline.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"

When I sign in the use of Security framework

Sign in using what API?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"

The “SecKeyRawSign” function used by.

I looked at the crash position as this function. “SecKeyRawSign”

Below is the crash log.




Incident Identifier: 87D43C82-B69F-4603-A9D0-5174A93DA0A2
CrashReporter Key: TODO
Hardware Model: iPhone9,1
Process: tztHuaTaiZLMobil [59358]
Path: /private/var/containers/Bundle/Application/95A26E3E-AB48-4867-9DAB-
Version: 7.0.1 (23028)
Code Type: ARM-64
Parent Process: ??? [1]

Date/Time: 2020-10-12 11:51:13 +0000
OS Version: iPhone OS 13.3.1 (17D50)
Report Version: 104

Exception Type: SIGABRT
Exception Codes: #0 at 0x18e311ec4
Crashed Thread: 3

Application Specific Information:
  • ** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unexpected sessionID mismatch'



The crash report shows that a crash occurred when I called SecKeyRawSign.I want to know the cause of the crash.Thank you for your reply.
Accepted Answer

The crash report shows that a crash occurred when I called
SecKeyRawSign.

Can you post the full crash report? Use the paperclip button to add it as a text attachment so that it doesn’t clog up the timeline.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
This attachment is my entire crash log.Sensitive information has been removed.The crash is in my lib.I looked at the crash position as this function. “SecKeyRawSign”



Thank you for your reply.
That is interesting. Here’s a symbolicated backtrace of the exception:

Code Block
13 Foundation … -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
14 CryptoTokenKit … -[TKClientTokenSession withError:accessControl:invoke:] + 540
15 CryptoTokenKit … -[TKClientTokenObject operation:data:algorithms:parameters:error:] + 264
16 Security … TKTokenCopyOperationResult + 604
17 Security … __SecCTKKeyCopyOperationResult_block_invoke + 452
18 Security … SecItemAuthDo + 124
19 Security … SecCTKKeyCopyOperationResult + 380
20 Security … SecKeyRunAlgorithmAndCopyResult + 248
21 Security … SecKeyCreateSignature + 104
22 Security … SecKeyPerformLegacyOperation + 172
23 Security … SecKeyRawSign + 132
24 tztHuaTaiZLMobile … -[gmrz_jv_ecc_cal_ext useKeyAsyncSign:serviceId:username:digestData:digestLeng…


In frame 24 your app has called SecKeyRawSign. Frames 23 through 17 are that call wending its way through the Security framework. In frame 16 it calls into CryptoTokenKit, because the key is stored on a secure token. Presumably this is the Secure Enclave, which is handled internally as a CryptoTokenKit token. Anyway, frames 15 and 14 are CryptoTokenKit and there’s where the Unexpected sessionID mismatch exception is coming from.

I don’t have a good idea as to why this is happening. How frequently does this happen? Is this crash report coming in from users in the field? Can you reproduce it yourself?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Thank you for your reply.This is happening on the customer device,Currently. there is a high frequency of iphone7 devices on ios 13.I didn't reproduce myself.The crash mentioned so far has not yet happened to ios14.

There is a high frequency of iPhone 7 devices on iOS 13.

Is there a good reason for that? For example, does your app ship to customers that use a lot of iPhone 7 devices? In a managed environment, for example?

The crash mentioned so far has not yet happened to iOS 14.

Do you have any analytics to confirm that your app is being used by a reasonable number of iOS 14 users? How about iPhone 7 users on iOS 14?

Honestly, this sounds like a bug in the system that’s been squashed in iOS 14 and answering the above questions should help you test that theory.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
There is not enough data analysis for the moment.
So far the feedback has only proved that there is a high frequency in ios13.
I also have another crash log.



My client has some statistics.



Looking forward to your reply.
I’m not sure how to read that table. Is it simply a list of all the crashes you’ve seen? If so, that seems to answer both of my questions:
  • Do you have any analytics to confirm that your app is being used by a reasonable number of iOS 14 users? — Your table includes examples of the crash on iOS 14.

  • How about iPhone 7 users on iOS 14? — You table includes examples of the crash on other devices.

Right?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Thank you for your reply.
  1. Do you have any analytics to confirm that your app is being used by a reasonable number of iOS 14 users? — Your table includes examples of the crash on iOS 14.

Currently available for current line crash device model
There are a lot of iphone7 devices.
  1. How about iPhone 7 users on iOS 14? — You table includes examples of the crash on other devices.

There are only a handful of iphone7's in ios14.

Statistics for all models are not currently available,But most of the problems are the same


ios13.6.1 'NSInternalInconsistencyException', reason: 'Unexpected sessionID mismatch'
 
 
Q