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 on app startup in realm core code due to non-strict ordering comparator #8028

Closed
jadar opened this issue Sep 18, 2024 · 6 comments · Fixed by #8029
Closed

Crash on app startup in realm core code due to non-strict ordering comparator #8028

jadar opened this issue Sep 18, 2024 · 6 comments · Fixed by #8029
Assignees

Comments

@jadar
Copy link

jadar commented Sep 18, 2024

SDK and version

SDK : Cocoa/Swift (Cocoa, Java, etc)
Version: v10.53.1

Observations

  • How frequent do the crash occur?
    • Every time
  • Does it happen in production or during dev/test?
    • Dev/Test
  • Can the crash be reproduced by you?
    • Yes
  • Can you provide instructions for how we can reproduce it?
    • Start app with our schema

Crash log / stacktrace

Realm notification listener (13)#0	0x000000018016c588 in __abort ()
#1	0x000000018016c4f8 in abort ()
#2	0x000000010c461598 in std::__1::__check_strict_weak_ordering_sorted[abi:de180100]<std::__1::unique_ptr<realm::ParentNode, std::__1::default_delete<realm::ParentNode>>*, realm::OrNode::combine_conditions(bool)::'lambda'(auto&, auto&)> at /Applications/Xcode-16.0.0.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator18.0.sdk/usr/include/c++/v1/__debug_utils/strict_weak_ordering_check.h:58
#3	0x000000010c461260 in std::__1::__sort_impl[abi:de180100]<std::__1::_ClassicAlgPolicy, std::__1::__wrap_iter<std::__1::unique_ptr<realm::ParentNode, std::__1::default_delete<realm::ParentNode>>*>, realm::OrNode::combine_conditions(bool)::'lambda'(auto&, auto&)> at /Applications/Xcode-16.0.0.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator18.0.sdk/usr/include/c++/v1/__algorithm/sort.h:998
#4	0x000000010c460d90 in std::__1::sort[abi:de180100]<std::__1::__wrap_iter<std::__1::unique_ptr<realm::ParentNode, std::__1::default_delete<realm::ParentNode>>*>, realm::OrNode::combine_conditions(bool)::'lambda'(auto&, auto&)> at /Applications/Xcode-16.0.0.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator18.0.sdk/usr/include/c++/v1/__algorithm/sort.h:1004
#5	0x000000010c4606e4 in realm::OrNode::combine_conditions at /Users/jacob/Library/Developer/Xcode/DerivedData/TractionField-czfssazbudivavdunakatdqiiajo/SourcePackages/checkouts/realm-core/src/realm/query_engine.hpp:2286
#6	0x000000010c45f74c in realm::OrNode::init at /Users/jacob/Library/Developer/Xcode/DerivedData/TractionField-czfssazbudivavdunakatdqiiajo/SourcePackages/checkouts/realm-core/src/realm/query_engine.hpp:2180
#7	0x000000010c3b9c64 in realm::Query::init at /Users/jacob/Library/Developer/Xcode/DerivedData/TractionField-czfssazbudivavdunakatdqiiajo/SourcePackages/checkouts/realm-core/src/realm/query.cpp:1883
#8	0x000000010c3ba038 in realm::Query::do_find_all at /Users/jacob/Library/Developer/Xcode/DerivedData/TractionField-czfssazbudivavdunakatdqiiajo/SourcePackages/checkouts/realm-core/src/realm/query.cpp:1413
#9	0x000000010c734564 in realm::TableView::do_sync at /Users/jacob/Library/Developer/Xcode/DerivedData/TractionField-czfssazbudivavdunakatdqiiajo/SourcePackages/checkouts/realm-core/src/realm/table_view.cpp:482
#10	0x000000010c734fd8 in realm::TableView::apply_descriptor_ordering at /Users/jacob/Library/Developer/Xcode/DerivedData/TractionField-czfssazbudivavdunakatdqiiajo/SourcePackages/checkouts/realm-core/src/realm/table_view.cpp:404
#11	0x000000010c20dd28 in realm::_impl::ResultsNotifier::run at /Users/jacob/Library/Developer/Xcode/DerivedData/TractionField-czfssazbudivavdunakatdqiiajo/SourcePackages/checkouts/realm-core/src/realm/object-store/impl/results_notifier.cpp:194
#12	0x000000010c1f00f8 in realm::_impl::RealmCoordinator::run_async_notifiers at /Users/jacob/Library/Developer/Xcode/DerivedData/TractionField-czfssazbudivavdunakatdqiiajo/SourcePackages/checkouts/realm-core/src/realm/object-store/impl/realm_coordinator.cpp:1030
#13	0x000000010c1ef600 in realm::_impl::RealmCoordinator::on_change at /Users/jacob/Library/Developer/Xcode/DerivedData/TractionField-czfssazbudivavdunakatdqiiajo/SourcePackages/checkouts/realm-core/src/realm/object-store/impl/realm_coordinator.cpp:894
#14	0x000000010c1861f4 in realm::_impl::ExternalCommitHelper::listen at /Users/jacob/Library/Developer/Xcode/DerivedData/TractionField-czfssazbudivavdunakatdqiiajo/SourcePackages/checkouts/realm-core/src/realm/object-store/impl/apple/external_commit_helper.cpp:234
#15	0x000000010c18695c in realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&, realm::RealmConfig const&)::$_0::operator()() const at /Users/jacob/Library/Developer/Xcode/DerivedData/TractionField-czfssazbudivavdunakatdqiiajo/SourcePackages/checkouts/realm-core/src/realm/object-store/impl/apple/external_commit_helper.cpp:175
#16	0x000000010c18690c in std::__1::__invoke[abi:de180100]<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&, realm::RealmConfig const&)::$_0> at /Applications/Xcode-16.0.0.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator18.0.sdk/usr/include/c++/v1/__type_traits/invoke.h:344
#17	0x000000010c1868e8 in std::__1::__thread_execute[abi:de180100]<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&, realm::RealmConfig const&)::$_0> at /Applications/Xcode-16.0.0.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator18.0.sdk/usr/include/c++/v1/__thread/thread.h:199
#18	0x000000010c1865f8 in std::__1::__thread_proxy[abi:de180100]<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&, realm::RealmConfig const&)::$_0>> at /Applications/Xcode-16.0.0.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator18.0.sdk/usr/include/c++/v1/__thread/thread.h:208
#19	0x0000000104bfb414 in _pthread_start ()

Steps & Code to Reproduce

I'm not sure what exactly is causing this, since the code crashes in Realm's internals. The context of the crashed code seems to be in sorting columns, which indicates to me it's a problem with something in our schema that is outside of the norm (unsure what that would be, we only just bumped the version to the latest non-v20 release.) It looks like the codepath goes through some code that was recently changed (thus would be the source of the different behavior, since the last time we updated was in April.) Suspected commit is eef7fcf#diff-251da97dc2f3dad702887aa32c15789820ee0c88eb5fc9db7be4b91e65e5f45aR2231

Copy link

sync-by-unito bot commented Sep 18, 2024

➤ PM Bot commented:

Jira ticket: RCORE-2259

@jadar
Copy link
Author

jadar commented Sep 18, 2024

I can confirm that downgrading to realm-swift version 10.49.3, which is the last version before #7582 was merged and release of realm-core v14.6.2 was made with the suspected changes. Therefore, realm-core version 14.5.2 does not seem to have the issues that later version have. Additionally, upgrading to the next version of realm-swift (10.50.0) which upgraded to core v14.6.2 results in the app crashing again.

@jedelbo jedelbo self-assigned this Sep 19, 2024
@jedelbo
Copy link
Contributor

jedelbo commented Sep 19, 2024

@jadar I have found the root cause of this issue, but I am not able to reproduce it. Can you tell what kind of query you are performing?

@jadar
Copy link
Author

jadar commented Sep 19, 2024

Can you tell what kind of query you are performing?

I'm really not sure. The exception happens in a Realm run loop. It doesn't appear that my app is doing any work. It happens during the launch phase of the app, before everything finished setting up. That's why I thought it happened during schema validation or something. Do you have any debugging tricks that I could use to figure out what Realm might be doing or responding to?

@jadar
Copy link
Author

jadar commented Sep 19, 2024

I can tell you that it doesn't crash on Xcode 15.4, but it does crash on 16.0 (16A242d).

@jedelbo
Copy link
Contributor

jedelbo commented Sep 19, 2024

Do you have any debugging tricks that I could use to figure out what Realm might be doing or responding to?

You might be able to enable some logging.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants