Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when adding an object to Realm (Corrupted Realm File) #7287

Closed
pierre-wehbe opened this issue Jun 15, 2021 · 7 comments
Closed

Crash when adding an object to Realm (Corrupted Realm File) #7287

pierre-wehbe opened this issue Jun 15, 2021 · 7 comments
Labels
More-information-needed More information is needed to progress. The issue will close automatically in 2 weeks. O-Community Reproduction-Required

Comments

@pierre-wehbe
Copy link

pierre-wehbe commented Jun 15, 2021

Goals

When app crashes, realm file should recover safely

Expected Results

Save objects into realm (without crash)

Actual Results

#9 0x0000000101e2ba3c in realm::Allocator::translate_critical(realm::Allocator::RefTranslation*, unsigned long) const at /realm-core/src/realm/alloc.hpp:580
#10 0x0000000101e21d88 in realm::Allocator::translate(unsigned long) const at /realm-core/src/realm/alloc.hpp:598
#11 0x0000000101fe5a00 in realm::StringData realm::Obj::getrealm::StringData(realm::ColKey::Idx) const at /realm-core/src/realm/obj.cpp:328
#12 0x0000000101fe5874 in realm::StringData realm::Obj::getrealm::StringData(realm::ColKey) const at /realm-core/src/realm/obj.cpp:204
#13 0x0000000101a6d428 in void realm::(anonymous namespace)::ValueUpdater<objc_object* __strong, RLMAccessorContext>::operator()realm::StringData(realm::StringData*) at /realm-core/src/realm/object-store/object_accessor.hpp:100
#14 0x0000000101a6bd50 in auto realm::switch_on_type<realm::Obj, realm::(anonymous namespace)::ValueUpdater<objc_object* __strong, RLMAccessorContext>&>(realm::PropertyType, realm::(anonymous namespace)::ValueUpdater<objc_object* __strong, RLMAccessorContext>&) at /realm-core/src/realm/object-store/property.hpp:235
#15 0x0000000101a6b70c in void realm::Object::set_property_value_impl<objc_object* __strong, RLMAccessorContext>(RLMAccessorContext&, realm::Property const&, objc_object* __strong, realm::CreatePolicy, bool) at /realm-core/src/realm/object-store/object_accessor.hpp:168
#16 0x0000000101a40034 in realm::Object realm::Object::create<objc_object* strong, RLMAccessorContext>(RLMAccessorContext&, std::1::shared_ptrrealm::Realm const&, realm::ObjectSchema const&, objc_object __strong, realm::CreatePolicy, realm::ObjKey, realm::Obj) at /realm-core/src/realm/object-store/object_accessor.hpp:350
#17 0x0000000101a3ee08 in RLMAccessorContext::createObject(objc_object
, realm::CreatePolicy, bool, realm::ObjKey) at /realm-cocoa/Realm/RLMAccessor.mm:972
#18 0x0000000101a40170 in realm::Obj RLMAccessorContext::unboxrealm::Obj(objc_object
, realm::CreatePolicy, realm::ObjKey) at /realm-cocoa/Realm/RLMAccessor.mm:1000
#19 0x0000000101a5e1f8 in auto void realm::List::set_if_different<objc_object* __strong&, RLMAccessorContext>(RLMAccessorContext&, unsigned long, objc_object* __strong&, realm::CreatePolicy)::'lambda'(objc_object* __strong&)::operator()realm::Obj*(objc_object* __strong&) const at /realm-core/src/realm/object-store/list.hpp:234
#20 0x0000000101a5d6fc in auto realm::switch_on_type<realm::Obj, void realm::List::set_if_different<objc_object* __strong&, RLMAccessorContext>(RLMAccessorContext&, unsigned long, objc_object* __strong&, realm::CreatePolicy)::'lambda'(objc_object* __strong&)>(realm::PropertyType, RLMAccessorContext&&) at /realm-core/src/realm/object-store/property.hpp:241
#21 0x0000000101a5d55c in auto realm::List::dispatch<void realm::List::set_if_different<objc_object* __strong&, RLMAccessorContext>(RLMAccessorContext&, unsigned long, objc_object* __strong&, realm::CreatePolicy)::'lambda'(objc_object* __strong&)>(objc_object* __strong&) const at /realm-core/src/realm/object-store/list.hpp:158
#22 0x0000000101a5bd70 in void realm::List::set_if_different<objc_object* __strong&, RLMAccessorContext>(RLMAccessorContext&, unsigned long, objc_object* __strong&, realm::CreatePolicy) at /realm-core/src/realm/object-store/list.hpp:230
#23 0x0000000101a6c1ec in auto void realm::List::assign<objc_object* __strong&, RLMAccessorContext>(RLMAccessorContext&, objc_object* __strong&, realm::CreatePolicy)::'lambda'(objc_object* __strong&)::operator()<objc_object* __strong&>(objc_object* __strong&) const at /realm-core/src/realm/object-store/list.hpp:267
#24 0x0000000101a6c03c in void RLMStatelessAccessorContext::enumerate_collection<void realm::List::assign<objc_object* __strong&, RLMAccessorContext>(RLMAccessorContext&, objc_object* __strong&, realm::CreatePolicy)::'lambda'(objc_object* __strong&)>(objc_object*, objc_object* __strong&) at /realm-cocoa/Realm/RLMAccessor.hpp:73
#25 0x0000000101a6b980 in void realm::List::assign<objc_object* __strong&, RLMAccessorContext>(RLMAccessorContext&, objc_object* __strong&, realm::CreatePolicy) at /realm-core/src/realm/object-store/list.hpp:263
#26 0x0000000101a6b3dc in void realm::Object::set_property_value_impl<objc_object* __strong, RLMAccessorContext>(RLMAccessorContext&, realm::Property const&, objc_object* __strong, realm::CreatePolicy, bool) at /realm-core/src/realm/object-store/object_accessor.hpp:143
#27 0x0000000101a40034 in realm::Object realm::Object::create<objc_object* strong, RLMAccessorContext>(RLMAccessorContext&, std::1::shared_ptrrealm::Realm const&, realm::ObjectSchema const&, objc_object __strong, realm::CreatePolicy, realm::ObjKey, realm::Obj) at /realm-core/src/realm/object-store/object_accessor.hpp:350
#28 0x0000000101a3ee08 in RLMAccessorContext::createObject(objc_object
, realm::CreatePolicy, bool, realm::ObjKey) at /realm-cocoa/Realm/RLMAccessor.mm:972
#29 0x0000000101a40170 in realm::Obj RLMAccessorContext::unboxrealm::Obj(objc_object
, realm::CreatePolicy, realm::ObjKey) at /realm-cocoa/Realm/RLMAccessor.mm:1000
#30 0x0000000101a6d938 in realm::(anonymous namespace)::ValueUpdater<objc_object* __strong, RLMAccessorContext>::operator()(realm::Obj*) at /realm-core/src/realm/object-store/object_accessor.hpp:86
#31 0x0000000101a6bd8c in auto realm::switch_on_type<realm::Obj, realm::(anonymous namespace)::ValueUpdater<objc_object* __strong, RLMAccessorContext>&>(realm::PropertyType, realm::(anonymous namespace)::ValueUpdater<objc_object* __strong, RLMAccessorContext>&) at /realm-core/src/realm/object-store/property.hpp:241
#32 0x0000000101a6b70c in void realm::Object::set_property_value_impl<objc_object* __strong, RLMAccessorContext>(RLMAccessorContext&, realm::Property const&, objc_object* __strong, realm::CreatePolicy, bool) at /realm-core/src/realm/object-store/object_accessor.hpp:168
#33 0x0000000101a40034 in realm::Object realm::Object::create<objc_object* *strong, RLMAccessorContext>(RLMAccessorContext&, std::1::shared_ptrrealm::Realm const&, realm::ObjectSchema const&, objc_object __strong, realm::CreatePolicy, realm::ObjKey, realm::Obj) at /realm-core/src/realm/object-store/object_accessor.hpp:350
#34 0x0000000101a3ee08 in RLMAccessorContext::createObject(objc_object
, realm::CreatePolicy, bool, realm::ObjKey) at /realm-cocoa/Realm/RLMAccessor.mm:972
#35 0x0000000101b3824c in RLMAddObjectToRealm at /realm-cocoa/Realm/RLMObjectStore.mm:131
#36 0x0000000101dd14e8 in Realm.add(
:update:) at /realm-cocoa/RealmSwift/Realm.swift:437

Steps for others to Reproduce

This has happened since 10.7.x++
Seems to happen when my phone runs low on memory (iPhone Storage) which crashes the app at some point and corrupts the realm file.
Downloading the container and trying to open with Realm studio fails (file is corrupted)

Code Sample

realm?.add(object, update: .modified)

Version of Realm and Tooling

Realm framework version: 10.7.2 and 10.8.0

Xcode version: 12.4

iOS/OSX version: 14.4

Dependency manager + version: SPM

@dianaafanador3
Copy link
Contributor

Hi @pierre-wehbe Can you provide any code so we can reproduce this issue?

@pierre-wehbe
Copy link
Author

Hi Diana,

Unfortunately I am unable to reproduce it as my guess going back to the context of when the crash happens is my physical device having very low storage. This caused my app along with other apps on my phone to crash upon open.

For more context, I am currently managing 2 realm files, both encrypted:

  • a really small one (That one was not corrupted as I was able to download the iOS container and decode/ open in realm studio
  • a larger one (~20Mb). This one was corrupted and I wasn't able to open it.

@pierre-wehbe
Copy link
Author

@dianaafanador3 Any updates on this one?

@dianaafanador3
Copy link
Contributor

Hi @pierre-wehbe sorry for not answering before, I'll try to reproduce this in the next two weeks. Without any code is really hard to reproduce this issues, so I'll try my best to do it.

@dianaafanador3
Copy link
Contributor

Hi @pierre-wehbe I haven't had time to take a look at this. Have you update Realm to the latest version (https://github.com/realm/realm-cocoa/releases/tag/v10.12.0). Can you tell if this error keeps happening after the update.

@bmunkholm
Copy link
Contributor

@pierre-wehbe Sorry we haven't been able to reproduce this. Have you still not seen this again?

@bmunkholm bmunkholm added the More-information-needed More information is needed to progress. The issue will close automatically in 2 weeks. label Nov 15, 2021
@no-response
Copy link

no-response bot commented Nov 29, 2021

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

@no-response no-response bot closed this as completed Nov 29, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
More-information-needed More information is needed to progress. The issue will close automatically in 2 weeks. O-Community Reproduction-Required
Projects
None yet
Development

No branches or pull requests

3 participants