Please help to better understand the crashes. Crashes details: with Core Data on iOS 14, Xcode 12

0

I don't have a lot of experience in this. I did not change nothing in my code, but after iOS 14, I started to get the crashes and only for iOS 14 operating systems. Maybe something changed in Core Data? Here is crashlog details and Firebase. Thanks a lot!

I tried to caught it and this is what I found:

==13048==ERROR: AddressSanitizer: allocator is out of memory trying to allocate 0x1a0 bytes
==13048==FATAL: AddressSanitizer: internal allocator is out of memory trying to allocate 0x50 bytes
AddressSanitizer report breakpoint hit. Use 'thread info -s' to get extended information about the report.
(lldb)  thread info -s
thread #1: tid = 0x12fa63, 0x00000001041961f8 libclang_rt.asan_ios_dynamic.dylib`__asan::AsanDie(), queue = 'SQLQueue 0x16572e2c0 for MyApp.sqlite', stop reason = AddressSanitizer detected: out-of-memory

{
  "access_size": 0,
  "access_type": 0,
  "address": 0,
  "description": "out-of-memory",
  "instrumentation_class": "AddressSanitizer",
  "pc": 0,
  "stop_type": "fatal_error"
}

My function, where I think I have the crash.

 (NSMutableArray *)getObjectsforEntity:(NSString *)strEntity sortBy:(NSString *)strSort isAscending:(BOOL)ascending predicate:(NSPredicate *)predicate {
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:strEntity];
    if (strSort) {
        NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:strSort ascending:ascending];
        [fetchRequest setSortDescriptors:[NSArray arrayWithObject:sort]];
    }
    if (predicate) {

        [fetchRequest setPredicate:predicate];
    }
    NSError *error;
    NSMutableArray *result = [[[[self managedObjectContext] executeFetchRequest:fetchRequest error:&error] mutableCopy ]autorelease];
    if (result == nil) {
        return [[NSMutableArray alloc] init];
    }
    return result;
}

Crashlog Thread 5 Crashed: 0 CoreData 0x000000019d9fb6b8 _PFObjectIDFastHash64 + 36 (NSBasicObjectID.m:707) 1 CoreData 0x000000019d9fb6b4 _PFObjectIDFastHash64 + 32 (NSBasicObjectID.m:706) 2 CoreFoundation 0x0000000197c1c10c __CFBasicHashRehash + 996 (CFBasicHash.c:477) 3 CoreFoundation 0x0000000197c1fdf4 CFBasicHashRemoveValue + 2352 (CFBasicHash.c:1386) 4 CoreFoundation 0x0000000197b3e2f8 CFDictionaryRemoveValue + 224 (CFDictionary.c:471) 5 CoreData 0x000000019d94b8e8 -[NSManagedObjectContext(_NSInternalAdditions) _forgetObject:propagateToObjectStore:removeFromRegistry:] + 120 (NSManagedObjectContext.m:5088) 6 CoreData 0x000000019d92b450 -[_PFManagedObjectReferenceQueue _processReferenceQueue:] + 864 (NSManagedObjectContext.m:5077) 7 CoreData 0x000000019da43578 __90-[NSManagedObjectContext(_NSInternalNotificationHandling) _registerAsyncReferenceCallback]_block_invoke + 68 (NSManagedObjectContext.m:8825) 8 CoreData 0x000000019da39b18 developerSubmittedBlockToNSManagedObjectContextPerform + 156 (NSManagedObjectContext.m:3880) 9 libdispatch.dylib 0x000000019782b280 _dispatch_client_callout + 16 (object.m:559) 10 libdispatch.dylib 0x00000001977d3fa8 _dispatch_lane_serial_drain$VARIANT$mp + 612 (inline_internal.h:2548) 11 libdispatch.dylib 0x00000001977d4a84 _dispatch_lane_invoke$VARIANT$mp + 424 (queue.c:3862) 12 libdispatch.dylib 0x00000001977de518 _dispatch_workloop_worker_thread + 712 (queue.c:6590) 13 libsystem_pthread.dylib 0x00000001dc7005a4 _pthread_wqthread + 272 (pthread.c:2193) 14 libsystem_pthread.dylib 0x00000001dc703874 start_wqthread + 8

Thread 5 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000000000000   x2: 0x0000000000000000   x3: 0x0000000155e57240
    x4: 0x0000000155e570c0   x5: 0x0000000155f2d800   x6: 0x0000000000000015   x7: 0x0000000000000000
    x8: 0x0000000000000005   x9: 0x000000019d9fb694  x10: 0x0000000157008200  x11: 0x0000000197dc6c60
   x12: 0x0000000000000002  x13: 0x0000000000080003  x14: 0x00000000deeea853  x15: 0x000000000000bed5
   x16: 0x00000001ab41abec  x17: 0x0000000000000002  x18: 0x0000000000000000  x19: 0x0000000000000000
   x20: 0x0000000000000000  x21: 0x0000000000000000  x22: 0x0000000155f80520  x23: 0x0000000000000047
   x24: 0x0000000000000000  x25: 0x0000000281857980  x26: 0x0000000000000001  x27: 0x0000000282e2c068
   x28: 0x0000000000000047   fp: 0x000000016f716070   lr: 0x000000019d9fb6b4
    sp: 0x000000016f716060   pc: 0x000000019d9fb6b8 cpsr: 0x80000000
   esr: 0x92000005 (Data Abort) byte read Translation fault

Firebase

First Crash

Crashed: com.apple.main-thread
0  CoreData                       0x1abc966b8 _PFObjectIDFastHash64 + 36
1  CoreFoundation                 0x1a5eb710c __CFBasicHashRehash + 996
2  CoreFoundation                 0x1a5ebadf4 CFBasicHashRemoveValue + 2352
3  CoreFoundation                 0x1a5dd92f8 CFDictionaryRemoveValue + 224
4  CoreData                       0x1abbe68e8 -[NSManagedObjectContext(_NSInternalAdditions) _forgetObject:propagateToObjectStore:removeFromRegistry:] + 120
5  CoreData                       0x1abbc6450 -[_PFManagedObjectReferenceQueue _processReferenceQueue:] + 864
6  CoreData                       0x1abc8e914 -[_PFAutoreleasePoolThunk dealloc] + 40
7  libobjc.A.dylib                0x1b96d2584 AutoreleasePoolPage::releaseUntil(objc_object**) + 200
8  libobjc.A.dylib                0x1b96d2460 objc_autoreleasePoolPop + 208
9  CoreFoundation                 0x1a5e98a1c _CFAutoreleasePoolPop + 28
10 CoreFoundation                 0x1a5e0da30 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 28
11 CoreFoundation                 0x1a5e0d634 __CFRunLoopDoTimer + 1004
12 CoreFoundation                 0x1a5e0cb14 __CFRunLoopDoTimers + 324
13 CoreFoundation                 0x1a5e06eb0 __CFRunLoopRun + 1912
14 CoreFoundation                 0x1a5e06200 CFRunLoopRunSpecific + 572
15 GraphicsServices               0x1bbf01598 GSEventRunModal + 160
16 UIKitCore                      0x1a86cc004 -[UIApplication _run] + 1052
17 UIKitCore                      0x1a86d15d8 UIApplicationMain + 164
18 MyApp                          0x100a53a00 main + 14 (AppDelegate.swift:14)
19 libdyld.dylib                  0x1a5ae5598 start + 4

Second crash

Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x1b791e148 object_getClass + 12
1  CoreData                       0x1a9f026b0 _PFObjectIDFastHash64 + 28
2  CoreFoundation                 0x1a412310c __CFBasicHashRehash + 996
3  CoreFoundation                 0x1a4126df4 CFBasicHashRemoveValue + 2352
4  CoreFoundation                 0x1a40452f8 CFDictionaryRemoveValue + 224
5  CoreData                       0x1a9e528e8 -[NSManagedObjectContext(_NSInternalAdditions) _forgetObject:propagateToObjectStore:removeFromRegistry:] + 120
6  CoreData                       0x1a9e32450 -[_PFManagedObjectReferenceQueue _processReferenceQueue:] + 864
7  CoreData                       0x1a9efa914 -[_PFAutoreleasePoolThunk dealloc] + 40
8  libobjc.A.dylib                0x1b793e584 AutoreleasePoolPage::releaseUntil(objc_object**) + 200
9  libobjc.A.dylib                0x1b793e460 objc_autoreleasePoolPop + 208
10 libdispatch.dylib              0x1a3d0e514 _dispatch_lane_serial_drain$VARIANT$armv81 + 592
11 libdispatch.dylib              0x1a3d0f01c _dispatch_lane_invoke$VARIANT$armv81 + 456
12 libdispatch.dylib              0x1a3d144a0 _dispatch_main_queue_callback_4CF$VARIANT$armv81 + 576
13 CoreFoundation                 0x1a4078c30 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
14 CoreFoundation                 0x1a40730e8 __CFRunLoopRun + 2480
15 CoreFoundation                 0x1a4072200 CFRunLoopRunSpecific + 572
16 GraphicsServices               0x1ba16d598 GSEventRunModal + 160
17 UIKitCore                      0x1a6938004 -[UIApplication _run] + 1052
18 UIKitCore                      0x1a693d5d8 UIApplicationMain + 164
19 MyApp                          0x1005e6d50 main + 15 (AppDelegate.swift:15)
20 libdyld.dylib                  0x1a3d51598 start + 4

Third crash

Crashed: NSManagedObjectContext 0x2826edc70
0  libsystem_kernel.dylib         0x1b429195c __pthread_kill + 8
1  libsystem_pthread.dylib        0x1cebbb9e8 pthread_kill + 212
2  libsystem_c.dylib              0x192cf8934 abort + 100
3  libsystem_malloc.dylib         0x1989c2030 _malloc_put + 554
4  libsystem_malloc.dylib         0x1989c22a4 malloc_zone_error + 100
5  libsystem_malloc.dylib         0x1989ab9f0 szone_free + 460
6  CoreFoundation                 0x18a0d86bc __CFBasicHashRehash + 2452
7  CoreFoundation                 0x18a0dbdf4 CFBasicHashRemoveValue + 2352
8  CoreFoundation                 0x189ffa2f8 CFDictionaryRemoveValue + 224
9  CoreData                       0x18fe078e8 -[NSManagedObjectContext(_NSInternalAdditions) _forgetObject:propagateToObjectStore:removeFromRegistry:] + 120
10 CoreData                       0x18fde7450 -[_PFManagedObjectReferenceQueue _processReferenceQueue:] + 864
11 CoreData                       0x18feff578 __90-[NSManagedObjectContext(_NSInternalNotificationHandling) _registerAsyncReferenceCallback]_block_invoke + 68
12 CoreData                       0x18fef5b18 developerSubmittedBlockToNSManagedObjectContextPerform + 156
13 libdispatch.dylib              0x189ce7280 _dispatch_client_callout + 16
14 libdispatch.dylib              0x189c8ffa8 _dispatch_lane_serial_drain$VARIANT$mp + 612
15 libdispatch.dylib              0x189c90a84 _dispatch_lane_invoke$VARIANT$mp + 424
16 libdispatch.dylib              0x189c9a518 _dispatch_workloop_worker_thread + 712
17 libsystem_pthread.dylib        0x1cebbc5a4 _pthread_wqthread + 272
18 libsystem_pthread.dylib        0x1cebbf874 start_wqthread + 8
ios
objective-c
core-data
ios14
xcode12
asked on Stack Overflow Oct 30, 2020 by Aeerien • edited Oct 31, 2020 by GeneCode

1 Answer

0

The error you are looking for is this,

CoreData 0x000000019da39b18 developerSubmittedBlockToNSManagedObjectContextPerform + 156

What this usually means that you are creating the object in one context and saving in another.

You should be able to pinpoint the issue by adding launch arguments for Core Data, for example -com.apple.CoreData.ConcurrencyDebug 1

You can read more about debugging in this great article.

answered on Stack Overflow Oct 30, 2020 by Stamenkovski

User contributions licensed under CC BY-SA 3.0