Crash on launch. Possibly LAContext/LAClient causing the crash.

Hey, I've been trying to pinpoint what is causing this crash, but I'm having troubles understanding the Apple Crash log. I understand that this crash is happening after the app is launched, because I know we call canEvaluatePolicy() and evaluatePolicy() when the login screen finished loading. But if you notice, the following error lines after that are not related to LocalAuthentication (or so I think), therefore I'm confused.

Here's the log:

Thread 0 Crashed:
0   libsystem_platform.dylib      	0x0000000217f95fc4 _platform_strlen + 4
1   Foundation                    	0x00000001a803539c -[NSXPCEncoder _encodeInvocation:isReply:into:] + 132 (NSXPCCoder.m:456)
2   Foundation                    	0x00000001a800686c -[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:withProxy:] + 1388 (NSXPCConnection.m:1506)
3   CoreFoundation                	0x00000001a680270c ___forwarding___ + 1128 (NSForwarding.m:3618)
4   CoreFoundation                	0x00000001a6801a60 _CF_forwarding_prep_0 + 96
5   LocalAuthentication           	0x00000001dd83c6b4 __64-[LAClient evaluatePolicy:options:uiDelegate:synchronous:reply:]_block_invoke + 240 (LAClient.m:541)
6   LocalAuthentication           	0x00000001dd83bc80 __47-[LAClient _performSynchronous:callId:finally:]_block_invoke + 584 (LAClient.m:441)
7   libdispatch.dylib             	0x00000001a64d4a2c _dispatch_client_callout + 20 (object.m:560)
8   libdispatch.dylib             	0x00000001a64e42d4 _dispatch_sync_invoke_and_complete + 56 (queue.c:1028)
9   LocalAuthentication           	0x00000001dd83b9e8 -[LAClient _performSynchronous:callId:finally:] + 220 (LAClient.m:460)
10  LocalAuthentication           	0x00000001dd83c57c -[LAClient evaluatePolicy:options:uiDelegate:synchronous:reply:] + 392 (LAClient.m:540)
11  LocalAuthentication           	0x00000001dd842d48 -[LAContext _evaluatePolicy:options:log:cid:synchronous:reply:] + 472 (LAContext.m:340)
12  LocalAuthentication           	0x00000001dd838364 -[LAContext _evaluatePolicy:options:log:cid:error:] + 284 (LAContext.m:387)
13  LocalAuthentication           	0x00000001dd838090 -[LAContext canEvaluatePolicy:error:] + 304 (LAContext.m:533)
14  APIGuard                      	0x0000000101fbb144 0x101fac000 + 61764
15  APIGuard                      	0x0000000101fb99b8 0x101fac000 + 55736
16  CoreFoundation                	0x00000001a67ff324 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 28 (CFNotificationCenter.c:652)
17  CoreFoundation                	0x00000001a689bac4 ___CFXRegistrationPost_block_invoke + 52 (CFNotificationCenter.c:173)
18  CoreFoundation                	0x00000001a686ecc0 _CFXRegistrationPost + 456 (CFNotificationCenter.c:199)
19  CoreFoundation                	0x00000001a681539c _CFXNotificationPost + 728 (CFNotificationCenter.c:1147)
20  Foundation                    	0x00000001a7fdc704 -[NSNotificationCenter postNotificationName:object:userInfo:] + 96 (NSNotification.m:560)

Replies

That’s an interesting backtrace you’ve got there. Can you post the full crash report? That might yield more clues.

For info on how to do that, see Posting a Crash Report.

Share and Enjoy

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

Hey Quinn, thanks! I added the full crash file here.

Thanks for the crash report.

You wrote:

I understand that this crash is happening after the app is launched

Well, all crashes happen after the app is launched (-: but I think you meant shortly after the app is launched. That’s definitely not the case here. The app has been running for about a day:

Date/Time:           2022-04-19 11:43:05.2631 -0400
Launch Time:         2022-04-18 05:13:59.9899 -0400

I’d like to get a better handle on the specific context this crashing code is running in. Looking at your main thread I see this:

Thread 0 name:
Thread 0 Crashed:
0   libsystem_platform.dylib … _platform_strlen + 4
1   Foundation               … -[NSXPCEncoder _encodeInvocation:isReply:into:] + 132 (NSXPCCoder.m:456)
2   Foundation               … -[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:wit…
3   CoreFoundation           … ___forwarding___ + 1128 (NSForwarding.m:3618)
4   CoreFoundation           … _CF_forwarding_prep_0 + 96
5   LocalAuthentication      … __64-[LAClient evaluatePolicy:options:uiDelegate:synchronous:reply:]_block_invok…
6   LocalAuthentication      … __47-[LAClient _performSynchronous:callId:finally:]_block_invoke + 584 (LAClient…
7   libdispatch.dylib        … _dispatch_client_callout + 20 (object.m:560)
8   libdispatch.dylib        … _dispatch_sync_invoke_and_complete + 56 (queue.c:1028)
9   LocalAuthentication      … -[LAClient _performSynchronous:callId:finally:] + 220 (LAClient.m:460)
10  LocalAuthentication      … -[LAClient evaluatePolicy:options:uiDelegate:synchronous:reply:] + 392 (LAClient…
11  LocalAuthentication      … -[LAContext _evaluatePolicy:options:log:cid:synchronous:reply:] + 472 (LAContext…
12  LocalAuthentication      … -[LAContext _evaluatePolicy:options:log:cid:error:] + 284 (LAContext.m:387)
13  LocalAuthentication      … -[LAContext canEvaluatePolicy:error:] + 304 (LAContext.m:533)
14  APIGuard                 … 0x101fac000 + 61764
15  APIGuard                 … 0x101fac000 + 55736
16  CoreFoundation           … __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 28 (CFNotificationCente…

The APIGuard framework is part of your app. Is that something you built? If so, what notification is it listening for?

Share and Enjoy

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

APIGuard is a security framework that we use, it initializes every time application(_ application: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool is triggered. This framework is a black box, so I can't see what the initialize function is doing, but I will reach out to them and ask some questions. What makes you think that this could be the issue?

What makes you think that this could be the issue?

I’m not sure if it’s the issue but frame 14 means it’s definitely involved, in that it’s the immediate caller of -canEvaluatePolicy:error:. My next question was gonna be to ask about the details of that code, but that only makes sense if you have the source for it.

Share and Enjoy

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