Code Block EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000004 Crashed: com.apple.root.user-initiated-qos 0 CoreData 0x1b85a87ac _PFObjectIDFastHash64 + 40 1 CoreFoundation 0x1b254e4f8 __CFBasicHashRehash + 992 2 CoreFoundation 0x1b2552414 CFBasicHashRemoveValue + 2384 3 CoreFoundation 0x1b2469ec0 CFDictionaryRemoveValue + 236 4 CoreData 0x1b84f51c0 -[NSManagedObjectContext(_NSInternalAdditions) _forgetObject:propagateToObjectStore:removeFromRegistry:] + 124 5 CoreData 0x1b84d46ec -[_PFManagedObjectReferenceQueue _processReferenceQueue:] + 860 6 CoreData 0x1b85a0734 -[_PFAutoreleasePoolThunk dealloc] + 48 7 libobjc.A.dylib 0x1c65bb81c AutoreleasePoolPage::releaseUntil(objc_object**) + 204 8 libobjc.A.dylib 0x1c65bb6e8 objc_autoreleasePoolPop + 212 9 libdispatch.dylib 0x1b2120aa4 _dispatch_last_resort_autorelease_pool_pop + 44 10 libdispatch.dylib 0x1b21313c8 _dispatch_root_queue_drain + 1064 11 libdispatch.dylib 0x1b21318e8 _dispatch_worker_thread2 + 116 12 libsystem_pthread.dylib 0x1f9a748cc _pthread_wqthread + 216 13 libsystem_pthread.dylib 0x1f9a7b77c start_wqthread + 8
_PFObjectIDFastHash64 Crash EXC_BAD_ACCESS KERN_INVALID_ADDRESS
As to why? I have no idea what-so-ever - but at least I can replicate it on demand.
The only fix I have right now is to use xCode 11.7 to build the app. I cannot crash it.
I have tried in 12.5 but not yet replicated the issue - but per the prior post it seems it is there too.
I can replicate it if I force quit my app while it is syncing data into core data. then if I go back in quickly it crashes. If I leave it a while (between the force quit - or I go back in again after the crash) then it does not crash. It is as though that there is something left over from the force quit that it does not like when I go in and sync data into core data again.
super annoying and very puzzling.
I am pushed latest build via xcode12.4, after that my app crashed randomly and some time frequently .
Have any solution, kindly let me know.
Thanks
Logs:
Thread 3 name: Dispatch queue: NSManagedObjectContext 0x282894000
Thread 3 Crashed:
0 libobjc.A.dylib 0x000000019ce066f4 object_getClass + 12
1 CoreData 0x000000018ee147a4 _PFObjectIDFastHash64 + 32
2 CoreFoundation 0x0000000188dba4f8 __CFBasicHashRehash + 992
3 CoreFoundation 0x0000000188dbe414 CFBasicHashRemoveValue + 2384
4 CoreFoundation 0x0000000188cd5ec0 CFDictionaryRemoveValue + 236
5 CoreData 0x000000018ed611c0 -[NSManagedObjectContext+ 299456 (_NSInternalAdditions) _forgetObject:propagateToObjectStore:removeFromRegistry:] + 124
6 CoreData 0x000000018ed406ec -[_PFManagedObjectReferenceQueue _processReferenceQueue:] + 860
7 CoreData 0x000000018ee5e198 __90-[NSManagedObjectContext+ 1335704 (_NSInternalNotificationHandling) _registerAsyncReferenceCallback]_block_invoke + 72
8 CoreData 0x000000018ee54410 developerSubmittedBlockToNSManagedObjectContextPerform + 164
9 libdispatch.dylib 0x000000018898cac8 _dispatch_client_callout + 20
10 libdispatch.dylib 0x0000000188993c08 _dispatch_lane_serial_drain + 580
11 libdispatch.dylib 0x0000000188994734 _dispatch_lane_invoke + 408
12 libdispatch.dylib 0x000000018899e528 _dispatch_workloop_worker_thread + 708
13 libsystem_pthread.dylib 0x00000001d0360908 _pthread_wqthread + 276
14 libsystem_pthread.dylib 0x00000001d036777c start_wqthread + 8
I found if remove some core data index. Crash will decrease, but still not resolved.
Why has this problem happened for so long, but the official did not reply ?
Hi, we've had the very same problem on an App that we inherited. After recompiling under Xcode 12 we started having this very same error every time there was a call to a moc. Ended with encaplusated every call in performBlock or performBlockAndWait fixed our problem. Hope this helps somebody.
We are observing the same issue on an app that was working fine before the latest release of iOS 14.6
For us ,the responsible code is :
[NSManagedObjectContext _disposeObjects:count:notifyParent:]
which is triggered when a user logs out of the app, and we reset every objects of our CoreData stack.
Hope there will be a fix some day, until then, we are going to go down the -com.apple.CoreData.ConcurrencyDebug 1 road and try to nest every CoreData call into a [NSManagedObjectContext performBlockAndWait:]
block.
I'm still encountering the same. Anyone have solution on this except downgrading to Xcode11.7 ?
Sorry I'm late to the game but here's how to actually fix this issue.
The Apple Engineer was correct, you'll need to add this flag to your scheme.
-com.apple.CoreData.ConcurrencyDebug 1
Xcode->Scheme->Edit Scheme->Arguments Tab
With the flag enabled, your code will break every place there is a concurrency issue with Core Data. The likely fix for this is to, (As the engineer pointed out) use perform
or performAndWait
where your NSManagedObjectContext
is called.
func save() {
context.performAndWait {
do {
try context.save()
} catch let error{
// Handle Error
}
}
}
The proper solution to this issue is to fix your concurrency bugs as suggested now in 3 replies. It's better for the app to crash than for state to become subtly corrupted for random users over time.
https://developer.apple.com/forums/thread/662240?answerId=637641022#637641022 https://developer.apple.com/forums/thread/662240?answerId=650357022#650357022 https://developer.apple.com/forums/thread/662240?answerId=705857022#705857022
Crashed: NSManagedObjectContext 0x281b95d40 0 CoreFoundation 0x11f80 __CFBasicHashRehash + 728 1 CoreFoundation 0x248a4 CFBasicHashRemoveValue + 452 2 CoreFoundation 0xf418 CFDictionaryRemoveValue + 196 3 CoreData 0x21448 -[NSManagedObjectContext(_NSInternalAdditions) _forgetObject:propagateToObjectStore:removeFromRegistry:] + 120 4 CoreData 0x2101c -[_PFManagedObjectReferenceQueue _processReferenceQueue:] + 616 5 CoreData 0x21dd4 __90-[NSManagedObjectContext(_NSInternalNotificationHandling) _registerAsyncReferenceCallback]_block_invoke + 80 6 CoreData 0x2074c developerSubmittedBlockToNSManagedObjectContextPerform + 156 7 libdispatch.dylib 0x4300 _dispatch_client_callout + 20 8 libdispatch.dylib 0xb894 _dispatch_lane_serial_drain + 748 9 libdispatch.dylib 0xc3c4 _dispatch_lane_invoke + 380 10 libdispatch.dylib 0x17004 _dispatch_root_queue_drain_deferred_wlh + 288 11 libdispatch.dylib 0x16878 _dispatch_workloop_worker_thread + 404 12 libsystem_pthread.dylib 0x1964 _pthread_wqthread + 288 13 libsystem_pthread.dylib 0x1a04 start_wqthread + 8
Same problem here in iOS17, is there any solution please comment