Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crash Core Data only in iOS 14

Tags:

I work on an app which use CoreData, everything works fine on iOS 13 and iOS 14 with differents Xcode betas. But since Apple released the official release for iOS 14 and Xcode 12 I have a crash when I try to get some objects from CoreData.

guard let customers = Customer.mr_findAllSorted(by: "login", ascending: true) as? [Customer] else { return }

Console output :

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't get value for 'batch' in bindings {
}.'

When I try to print the object from console log with breakpoint, I have a memory address of object but when I try to print some values of this object I have this error :

error: warning: couldn't get required object pointer (substituting NULL): Couldn't load 'self' because its value couldn't be evaluated

error: Execution was interrupted, reason: internal ObjC exception breakpoint(-5)..
The process has been returned to the state before expression evaluation.

Has anyone ever had to deal with this type of errors since the official versions ?

Thanks in advance for your help.

like image 903
fl0_9 Avatar asked Sep 21 '20 16:09

fl0_9


2 Answers

We're seeing this too in our app. It is only reproducible with iOS 14 and apparently the latest SDKs in Xcode 12.0.1, but we don't have any solutions or answers as to why this is occurring yet.

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't get value for 'batch' in bindings {
}.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff2043a126 __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x00007fff20177f78 objc_exception_throw + 48
    2   Foundation                          0x00007fff2088bedc -[NSVariableExpression _expressionWithSubstitutionVariables:] + 0
    3   Foundation                          0x00007fff2075ac7b -[NSComparisonPredicate evaluateWithObject:substitutionVariables:] + 264
    4   CoreData                            0x00007fff2511ec68 -[NSDictionaryStoreMap handleFetchRequest:] + 481
    5   CoreData                            0x00007fff2511dfd2 -[NSMappedObjectStore executeFetchRequest:withContext:] + 230
    6   CoreData                            0x00007fff251e10a2 __65-[NSPersistentStoreCoordinator executeRequest:withContext:error:]_block_invoke.797 + 3219
    7   CoreData                            0x00007fff251d988d __55-[NSPersistentStoreCoordinator _routeHeavyweightBlock:]_block_invoke + 55
    8   CoreData                            0x00007fff251edf0a gutsOfBlockToNSPersistentStoreCoordinatorPerform + 182
    9   libdispatch.dylib                   0x000000010a6b0a88 _dispatch_client_callout + 8
    10  libdispatch.dylib                   0x000000010a6bfcac _dispatch_lane_barrier_sync_invoke_and_complete + 132
    11  CoreData                            0x00007fff251d9492 _perform + 169
    12  CoreData                            0x00007fff251d9740 -[NSPersistentStoreCoordinator _routeHeavyweightBlock:] + 172
    13  CoreData                            0x00007fff250d640e -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 1684
    14  CoreData                            0x00007fff250d49c2 -[NSManagedObjectContext executeFetchRequest:error:] + 885
    15  CoreData                            0x00007fff251a9d7f -[NSManagedObjectContext _parentObjectsForFetchRequest:inContext:error:] + 477
    16  CoreData                            0x00007fff251aa774 __82-[NSManagedObjectContext(_NestedContextSupport) executeRequest:withContext:error:]_block_invoke + 603
    17  CoreData                            0x00007fff25109de8 internalBlockToNSManagedObjectContextPerform + 89
    18  libdispatch.dylib                   0x000000010a6b0a88 _dispatch_client_callout + 8
    19  libdispatch.dylib                   0x000000010a6bfcac _dispatch_lane_barrier_sync_invoke_and_complete + 132
    20  CoreData                            0x00007fff25109d6f _perform + 196
    21  CoreData                            0x00007fff25109b93 -[NSManagedObjectContext(_NestedContextSupport) executeRequest:withContext:error:] + 175
    22  CoreData                            0x00007fff250d49c2 -[NSManagedObjectContext executeFetchRequest:error:] + 885
    23  CoreData                            0x00007fff251a9d7f -[NSManagedObjectContext _parentObjectsForFetchRequest:inContext:error:] + 477
    24  CoreData                            0x00007fff251aa774 __82-[NSManagedObjectContext(_NestedContextSupport) executeRequest:withContext:error:]_block_invoke + 603
    25  CoreData                            0x00007fff25109de8 internalBlockToNSManagedObjectContextPerform + 89
    26  libdispatch.dylib                   0x000000010a6b0a88 _dispatch_client_callout + 8
    27  libdispatch.dylib                   0x000000010a6bfe11 _dispatch_async_and_wait_invoke + 175
    28  libdispatch.dylib                   0x000000010a6b0a88 _dispatch_client_callout + 8
    29  libdispatch.dylib                   0x000000010a6bef23 _dispatch_main_queue_callback_4CF + 1152
    30  CoreFoundation                      0x00007fff203a8276 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    31  CoreFoundation                      0x00007fff203a2b06 __CFRunLoopRun + 2685
    32  CoreFoundation                      0x00007fff203a1b9e CFRunLoopRunSpecific + 567
    33  GraphicsServices                    0x00007fff2b773db3 GSEventRunModal + 139
    34  UIKitCore                           0x00007fff24660af3 -[UIApplication _run] + 912
    35  UIKitCore                           0x00007fff24665a04 UIApplicationMain + 101
    36  XXXX                                0x0000000106de2d69 main + 153
    37  libdyld.dylib                       0x00007fff20257415 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't get value for 'batch' in bindings {
}.'
like image 60
archsten Avatar answered Sep 30 '22 20:09

archsten


You may set batch size to 0 [NSManagedObject MR_setDefaultBatchSize:0];, but check you performance after.

like image 37
Bogdan Avatar answered Sep 30 '22 21:09

Bogdan