Strange crash caused by accessing SecAccessControlCreateFlags inside a SDK

I am developing a SDK which uses SecAccessControlCreateFlags to mange key pairs generated and stored in Secure Enclave. The private key is protected by biometric and I'm using [.privateKeyUsage, .biometryCurrentSet] configuration when generating the key pair. Everything works perfectly in my demo app.

But when my partners integrate the SDK into their apps, the app crash with the exception as in the screenshot below.

The strange thing is, the SDK is not initialised and no API from the SDK is being called at this moment. The app crashes just by linking the SDK into the app. If I comment out any line of code [.privateKeyUsage, .biometryCurrentSet], the integration works again and the app doesn't crash.

I'm aware that the partner's apps also have similar functionality to manage their own key pairs, but from my understanding, it should not conflict with our own logic, since the key pairs are generated with different labels.

I'm completely lost now and have no idea how to fix this crash. Google doesn't help either.

Anyone has experienced the same issue and know what is going on here?

EXC_BAD_ACCESS is an operating system trap indicating your program is trying to access the contents of an illegal address. In your case, if you look at the error message, you're trying to access contents of a null pointer (address = 0x0). Seems like you might have type of memory corruption issue.

I've seen this happen when the application is pre-loading the dynamic libraries, which occurs before any code gets executed.

2 Likes

I’ve seen things like this crop up in a couple of situations:

  • SDK version mismatch, that is, the library and the library client were built with different SDK versions

  • Deployment target mismatch, that is, the library client has a lower deployment target than the library itself

Also, if your run your app outside of Xcode it should generate a crash report and that may have helpful info in it. See Diagnosing Issues Using Crash Reports and Device Logs.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

1 Like