realm-swift
realm-swift copied to clipboard
Crash in realm::NodeHeader::get_size_from_header
!!! MANDATORY TO FILL OUT !!!
Goals
Working app
Expected Results
No crash
Actual Results
Realm crashed
Steps for others to Reproduce
No steps
Code Sample
#0 0x0000000104197e9c in realm::NodeHeader::get_size_from_header(char const*) at /Users/v.marvin/Library/Developer/Xcode/DerivedData/Moosic-fzofypbagbknnhdsxvcwiilrnyef/SourcePackages/checkouts/realm-core/src/realm/node_header.hpp:116
#1 0x0000000104196e80 in realm::NodeHeader::get_byte_size_from_header(char const*) at /Users/v.marvin/Library/Developer/Xcode/DerivedData/Moosic-fzofypbagbknnhdsxvcwiilrnyef/SourcePackages/checkouts/realm-core/src/realm/node_header.hpp:205
#2 0x0000000104196c1c in realm::Allocator::translate_less_critical(realm::Allocator::RefTranslation*, unsigned long) const at /Users/v.marvin/Library/Developer/Xcode/DerivedData/Moosic-fzofypbagbknnhdsxvcwiilrnyef/SourcePackages/checkouts/realm-core/src/realm/alloc.cpp:143
#3 0x0000000103ed3318 in realm::Allocator::translate_critical(realm::Allocator::RefTranslation*, unsigned long) const at /Users/v.marvin/Library/Developer/Xcode/DerivedData/Moosic-fzofypbagbknnhdsxvcwiilrnyef/SourcePackages/checkouts/realm-core/src/realm/alloc.hpp:567
#4 0x0000000103ed3178 in realm::Allocator::translate(unsigned long) const at /Users/v.marvin/Library/Developer/Xcode/DerivedData/Moosic-fzofypbagbknnhdsxvcwiilrnyef/SourcePackages/checkouts/realm-core/src/realm/alloc.hpp:575
#5 0x0000000103ed30d4 in realm::Array::init_from_ref(unsigned long) at /Users/v.marvin/Library/Developer/Xcode/DerivedData/Moosic-fzofypbagbknnhdsxvcwiilrnyef/SourcePackages/checkouts/realm-core/src/realm/array.hpp:166
#6 0x0000000103ed83fc in realm::_impl::GroupFriend::get_history_ref(realm::Allocator&, unsigned long) at /Users/v.marvin/Library/Developer/Xcode/DerivedData/Moosic-fzofypbagbknnhdsxvcwiilrnyef/SourcePackages/checkouts/realm-core/src/realm/group.hpp:1202
#7 0x0000000103ef58a4 in bool realm::Transaction::internal_advance_read<(anonymous namespace)::TransactLogValidator>((anonymous namespace)::TransactLogValidator*, realm::VersionID, realm::_impl::History&, bool) at /Users/v.marvin/Library/Developer/Xcode/DerivedData/Moosic-fzofypbagbknnhdsxvcwiilrnyef/SourcePackages/checkouts/realm-core/src/realm/db.hpp:966
#8 0x0000000103ee4da0 in void realm::Transaction::advance_read<(anonymous namespace)::TransactLogValidator>((anonymous namespace)::TransactLogValidator*, realm::VersionID) at /Users/v.marvin/Library/Developer/Xcode/DerivedData/Moosic-fzofypbagbknnhdsxvcwiilrnyef/SourcePackages/checkouts/realm-core/src/realm/db.hpp:850
#9 0x0000000103ef66f0 in auto realm::_impl::transaction::advance(std::__1::shared_ptr<realm::Transaction> const&, realm::BindingContext*, realm::_impl::NotifierPackage&)::$_1::operator()<(anonymous namespace)::TransactLogValidator*>((anonymous namespace)::TransactLogValidator*&&) const at /Users/v.marvin/Library/Developer/Xcode/DerivedData/Moosic-fzofypbagbknnhdsxvcwiilrnyef/SourcePackages/checkouts/realm-core/src/realm/object-store/impl/transact_log_handler.cpp:621
#10 0x0000000103ee4f44 in void (anonymous namespace)::advance_with_notifications<realm::_impl::transaction::advance(std::__1::shared_ptr<realm::Transaction> const&, realm::BindingContext*, realm::_impl::NotifierPackage&)::$_1>(realm::BindingContext*, std::__1::shared_ptr<realm::Transaction> const&, realm::_impl::transaction::advance(std::__1::shared_ptr<realm::Transaction> const&, realm::BindingContext*, realm::_impl::NotifierPackage&)::$_1&&, realm::_impl::NotifierPackage&) at /Users/v.marvin/Library/Developer/Xcode/DerivedData/Moosic-fzofypbagbknnhdsxvcwiilrnyef/SourcePackages/checkouts/realm-core/src/realm/object-store/impl/transact_log_handler.cpp:565
#11 0x0000000103ee4df4 in realm::_impl::transaction::advance(std::__1::shared_ptr<realm::Transaction> const&, realm::BindingContext*, realm::_impl::NotifierPackage&) at /Users/v.marvin/Library/Developer/Xcode/DerivedData/Moosic-fzofypbagbknnhdsxvcwiilrnyef/SourcePackages/checkouts/realm-core/src/realm/object-store/impl/transact_log_handler.cpp:618
#12 0x0000000103ea2e2c in realm::_impl::RealmCoordinator::advance_to_ready(realm::Realm&) at /Users/v.marvin/Library/Developer/Xcode/DerivedData/Moosic-fzofypbagbknnhdsxvcwiilrnyef/SourcePackages/checkouts/realm-core/src/realm/object-store/impl/realm_coordinator.cpp:1107
#13 0x0000000103fac47c in realm::Realm::notify() at /Users/v.marvin/Library/Developer/Xcode/DerivedData/Moosic-fzofypbagbknnhdsxvcwiilrnyef/SourcePackages/checkouts/realm-core/src/realm/object-store/shared_realm.cpp:766
#14 0x0000000103f0285c in realm::_impl::WeakRealmNotifier::bind_to_scheduler()::$_0::operator()() const at /Users/v.marvin/Library/Developer/Xcode/DerivedData/Moosic-fzofypbagbknnhdsxvcwiilrnyef/SourcePackages/checkouts/realm-core/src/realm/object-store/impl/weak_realm_notifier.cpp:51
#15 0x0000000103f02800 in decltype(std::__1::forward<realm::_impl::WeakRealmNotifier::bind_to_scheduler()::$_0&>(fp)()) std::__1::__invoke<realm::_impl::WeakRealmNotifier::bind_to_scheduler()::$_0&>(realm::_impl::WeakRealmNotifier::bind_to_scheduler()::$_0&) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/type_traits:3545
#16 0x0000000103f027b4 in void std::__1::__invoke_void_return_wrapper<void>::__call<realm::_impl::WeakRealmNotifier::bind_to_scheduler()::$_0&>(realm::_impl::WeakRealmNotifier::bind_to_scheduler()::$_0&) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__functional_base:348
#17 0x0000000103f0278c in std::__1::__function::__alloc_func<realm::_impl::WeakRealmNotifier::bind_to_scheduler()::$_0, std::__1::allocator<realm::_impl::WeakRealmNotifier::bind_to_scheduler()::$_0>, void ()>::operator()() at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/functional:1546
#18 0x0000000103f00cbc in std::__1::__function::__func<realm::_impl::WeakRealmNotifier::bind_to_scheduler()::$_0, std::__1::allocator<realm::_impl::WeakRealmNotifier::bind_to_scheduler()::$_0>, void ()>::operator()() at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/functional:1720
#19 0x0000000103f44b24 in std::__1::__function::__value_func<void ()>::operator()() const at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/functional:1873
#20 0x0000000103f3a0d8 in std::__1::function<void ()>::operator()() const at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/functional:2548
#21 0x000000010415c208 in invocation function for block in (anonymous namespace)::DispatchQueueScheduler::set_notify_callback(std::__1::function<void ()>) at /Users/v.marvin/Library/Developer/Xcode/DerivedData/Moosic-fzofypbagbknnhdsxvcwiilrnyef/SourcePackages/checkouts/realm-core/src/realm/object-store/util/apple/scheduler.hpp:191
#22 0x000000010cd876f4 in _dispatch_call_block_and_release ()
#23 0x000000010cd88c78 in _dispatch_client_callout ()
#24 0x000000010cd90bf4 in _dispatch_lane_serial_drain ()
#25 0x000000010cd918ec in _dispatch_lane_invoke ()
#26 0x000000010cd9b77c in _dispatch_workloop_worker_thread ()
#27 0x000000021df5e114 in _pthread_wqthread ()
#28 0x000000021df60cd4 in start_wqthread ()
Enqueued from com.apple.root.default-qos.overcommit (Thread 17) Queue : com.apple.root.default-qos.overcommit (serial)
#0 0x000000010cd8da1c in dispatch_async ()
#1 0x000000010415bf50 in (anonymous namespace)::DispatchQueueScheduler::notify() at /Users/v.marvin/Library/Developer/Xcode/DerivedData/Moosic-fzofypbagbknnhdsxvcwiilrnyef/SourcePackages/checkouts/realm-core/src/realm/object-store/util/apple/scheduler.hpp:186
#2 0x0000000103effc88 in realm::_impl::WeakRealmNotifier::notify() at /Users/v.marvin/Library/Developer/Xcode/DerivedData/Moosic-fzofypbagbknnhdsxvcwiilrnyef/SourcePackages/checkouts/realm-core/src/realm/object-store/impl/weak_realm_notifier.cpp:41
#3 0x0000000103ea10c0 in realm::_impl::RealmCoordinator::on_change() at /Users/v.marvin/Library/Developer/Xcode/DerivedData/Moosic-fzofypbagbknnhdsxvcwiilrnyef/SourcePackages/checkouts/realm-core/src/realm/object-store/impl/realm_coordinator.cpp:817
#4 0x0000000103e43d98 in realm::_impl::ExternalCommitHelper::listen() at /Users/v.marvin/Library/Developer/Xcode/DerivedData/Moosic-fzofypbagbknnhdsxvcwiilrnyef/SourcePackages/checkouts/realm-core/src/realm/object-store/impl/apple/external_commit_helper.cpp:233
#5 0x0000000103e47f94 in realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0::operator()() const at /Users/v.marvin/Library/Developer/Xcode/DerivedData/Moosic-fzofypbagbknnhdsxvcwiilrnyef/SourcePackages/checkouts/realm-core/src/realm/object-store/impl/apple/external_commit_helper.cpp:174
#6 0x0000000103e47f30 in decltype(std::__1::forward<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>(fp)()) std::__1::__invoke<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>(realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0&&) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/type_traits:3545
#7 0x0000000103e47e90 in void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0>&, std::__1::__tuple_indices<>) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/thread:273
#8 0x0000000103e4758c in void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&)::$_0> >(void*) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/thread:284
#9 0x000000021df5d2c0 in _pthread_body ()
#10 0x000000021df5d220 in _pthread_start ()
#11 0x000000021df60cdc in thread_start ()
Version of Realm and Tooling
Realm framework version: Realm 10.5.0 / RealmDatabase 10.3.2
Realm Object Server version: Not used
Xcode version: 12.3
iOS/OSX version: 12.4 (iPhone 6S)
Dependency manager + version: Swift package manager.
Hi @igrechuhin,
Thank you for providing the above mentioned information.
Could you add a code example so that we can reproduce your issue on our side?
Thanks!
Kind regards, Dominic
@DominicFrei sorry but it’s not stable. It just happens from time to time in our app. We have no steps or test code to reproduce it. In fact, we have tried to provide as much info as we could. If you say what other info/variables we should check next time we’ll encounter this crash, I’ll try to provide it to you.
@igrechuhin Ok, I understand you. It's hard to say what would be helpful. Or rather which information you could provide, since it's not reproducible. Trying to get more people in here, maybe someone has seen something similar before.
@jedelbo Could this be related to a notification subscription?
@igrechuhin are you observing any Realm
's or Object
's anywhere in your code? If you could give us some context on how you are using Realm that would be great.
@leemaguire we have dedicated thread with run loop to make subscriptions. Please check the attached files: Subscription.zip
I've also tracked number_of_versions that is from your code located at /realm-core/src/realm/db.cpp
It turns out that from time to time, when we have active phase of storing network data and at the same time based on subscription notifications get frozen lists (to make sure those are not mutated while being enumerated), number_of_versions increases to 10+ (can even hit 30). It drops very fast to 2 (I've tracked it after update, so it's 1 when no one accesses database), but it seems to me that these peaks lead to crash due to instant memory requirements.
Is there any way we/you can control the number of snapshots and wait for number_of_versions to fall below reasonable value before proceeding?
We do already control number of opened Realm / threads / queues accessing the database. But even 2 Realms can create 10+ number_of_versions.
@igrechuhin we do expose a maximumNumberOfActiveVersions
you can use to track active snapshots. You can set it from the Realm Configuration.
@igrechuhin do you have any progress with resolving this issue?
Closing as we have made significant changes to the Core codebase since this issue was opened. If the problem persists on the latest version of Realm please open a new issue.