realm-core: Object has been deleted or invalidated.
SDK and version
SDK : Swift Version: Realm: 10.28.6 RealmDatabase: 12.5.1
App crashes when this code runs.
let realm = try Realm()
let fetchResult = realm.objects(HLAsset.self).filter("assetCollection=%@", hlAssetCollection)
for i in 0 ..< fetchResult!.count {
print(fetchResult![i].identifier) // => crash (not crashed for all object. explained below)
}
App was working well (database was OK). Added some objects to database. (nothing special) Exited an app. App runs => crash



You can see something is wrong with this screenshot. When I open the realm file with Realm Studio, there are objects have same identifier(Primary Key). I don’t know how this can happen. When reading other objects, there is no problem. But when reading objects like this (some objects have same identifier), app crashes.

When I tried to save data as JSON, it failed. When I tried to save data as Local Realm, it saved .realm file(size changed from 167.1MB to 23.1MB) but it is not opened with Realm Studio nor an app.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (9 by maintainers)
@keerthika-priya It’s not released yet. The fix/pr is in realm-core 12.12.0, which is not yet included in a released realm-swift version: https://github.com/realm/realm-swift/blob/master/CHANGELOG.md
@BlueCobold @keerthika-priya Version v10.33.0 https://github.com/realm/realm-swift/releases/tag/v10.33.0 has been released with the fix
@BlueCobold @BlueCobold We sure gonna do a release next week.
@keerthika-priya No. I’m not working for Realm/Mongo and I’m waiting for that release myself.
@BlueCobold Thanks for mentioning! Something got messed up when the issue was transferred from the Swift Repo.
The database has some references pointing in the wrong direction. So it is clearly broken. I will take the issue back to core and make some further analysis on the file.
@leemaguire I can investigate.