[NSUserDefaults(NSUserDefaults) _initWithSuiteName:container:] Crash

In iOS 18, we encountered a crash:

Thread 4 name:  com.apple.root.user-interactive-qos
Thread 4 Crashed:
0   CoreFoundation                          0x18c4f9b10 __CFCheckCFInfoPACSignature + 4
1   CoreFoundation                          0x18c53ed64 CFBundleGetInfoDictionary + 24
2   CoreFoundation                          0x18c53ed1c CFBundleGetIdentifier + 16
3   Foundation                              0x18b153740 -[NSUserDefaults(NSUserDefaults) _initWithSuiteName:container:] + 84
4   UIKitCore                               0x18ef26ef0 ___UIKitUserDefaults_block_invoke + 40
5   libdispatch.dylib                       0x1941ee0d0 _dispatch_client_callout + 20
6   libdispatch.dylib                       0x1941ef918 _dispatch_once_callout + 32
7   UIKitCore                               0x18ef9de28 _UIKitUserDefaults + 80
8   UIKitCore                               0x18f058a7c ___UIKitPreferencesOnce_block_invoke + 20
9   libdispatch.dylib                       0x1941ee0d0 _dispatch_client_callout + 20
10  libdispatch.dylib                       0x1941ef918 _dispatch_once_callout + 32
11  UIKitCore                               0x18f056c8c _UIKitPreferencesOnce + 80
12  UIKitCore                               0x18f0563b8 ___UIApplicationMainPreparations_block_invoke + 20
13  libdispatch.dylib                       0x1941ec370 _dispatch_call_block_and_release + 32
14  libdispatch.dylib                       0x1941ee0d0 _dispatch_client_callout + 20
15  libdispatch.dylib                       0x1941fff60 _dispatch_root_queue_drain + 860
16  libdispatch.dylib                       0x194200590 _dispatch_worker_thread2 + 156
17  libsystem_pthread.dylib                 0x2136ffc40 _pthread_wqthread + 228
18  libsystem_pthread.dylib                 0x2136fc488 start_wqthread + 8

Below image show more details:

And after set a symbol breakpoint:

[NSUserDefaults _initWithSuiteName:container:]

We found that at the beginning of app launch, the system will call it:

It not always crash, but sometimes especially when app upgrade, what the root cause maybe?

Answered by DTS Engineer in 821962022

Hi @Allen-Chen , from this crash it quite difficult to understand what happens. Anyway, It seems that app try to read CFBundleInfoDictionary and crash on __CFCheckCFInfoPACSignature , that if I remember correctly its a low level API on ARM for memory corruption. Probably you could enable on Xcode memory debug tools. Read this topics, it seems similar to your use case https://forums.developer.apple.com/forums/thread/764538

Regards Rob

[NSUserDefaults(NSUserDefaults) _initWithSuiteName:container:] Crash
 
 
Q