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 in table.hpp:251: [realm-core-10.1.4] Assertion failed: !key.is_unresolved() #3611

Closed
RosenTomov opened this issue Feb 23, 2021 · 15 comments
Assignees

Comments

@RosenTomov
Copy link

RosenTomov commented Feb 23, 2021

Replaced names with "App".

Crash Report

Realm notification listener (41): signal SIGABRT
/node_modules/realm/vendor/realm-ios/include/realm/table.hpp:251: [realm-core-10.1.4] Assertion failed: !key.is_unresolved()
0   App                        0x000000010a9c4a8c _ZN5realm4utilL18terminate_internalERNSt3__118basic_stringstreamIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 28
1   App                        0x000000010a9c4d7b _ZN5realm4util9terminateEPKcS2_lOSt16initializer_listINS0_9PrintableEE + 395
2   App                        0x0000000109ec55ea _ZNK5realm5Table10get_objectENS_6ObjKeyE + 122
3   App                        0x0000000109ec523f _ZN5realm5_impl17DeepChangeChecker20check_outgoing_linksENS_8TableKeyERKNS_5TableExm + 303
4   App                        0x0000000109ec58f8 _ZN5realm5_impl17DeepChangeChecker9check_rowERKNS_5TableExm + 488
5   App                        0x0000000109edfb44 _ZZZN5realm5_impl17DeepChangeChecker20check_outgoing_linksENS_8TableKeyERKNS_5TableExmENK3$_7clERKNS1_12OutgoingLinkEENKUlT_E_clINS_6ObjKeyEEEDaSA_ + 52
6   App                        0x0000000109ede147 _ZNSt3__1L6any_ofIN5realm11LstIteratorINS1_6ObjKeyEEEZZNS1_5_impl17DeepChangeChecker20check_outgoing_linksENS1_8TableKeyERKNS1_5TableExmENK3$_7clERKNS6_12OutgoingLinkEEUlT_E_EEbSF_SF_T0_ + 87
7   App                        0x0000000109edde79 _ZZN5realm5_impl17DeepChangeChecker20check_outgoing_linksENS_8TableKeyERKNS_5TableExmENK3$_7clERKNS1_12OutgoingLinkE + 713
8   App                        0x0000000109ec5667 _ZNSt3__1L6any_ofINS_11__wrap_iterIPKN5realm5_impl17DeepChangeChecker12OutgoingLinkEEEZNS4_20check_outgoing_linksENS2_8TableKeyERKNS2_5TableExmE3$_7EEbT_SE_T0_ + 71
9   App                        0x0000000109ec536f _ZN5realm5_impl17DeepChangeChecker20check_outgoing_linksENS_8TableKeyERKNS_5TableExm + 607
10  App                        0x0000000109ec58f8 _ZN5realm5_impl17DeepChangeChecker9check_rowERKNS_5TableExm + 488
11  App                        0x0000000109ec5bc3 _ZN5realm5_impl17DeepChangeCheckerclEx + 99
12  App                        0x0000000109edb1e2 _ZNSt3__1L8__invokeIRN5realm5_impl17DeepChangeCheckerEJxEEEDTclclsr3std3__1E7forwardIT_Efp_Espclsr3std3__1E7forwardIT0_Efp0_EEEOS5_DpOS6_ + 50
13  App                        0x0000000109edb182 _ZNSt3__128__invoke_void_return_wrapperIbE6__callIJRN5realm5_impl17DeepChangeCheckerExEEEbDpOT_ + 50
14  App                        0x0000000109edb142 _ZNSt3__110__function12__alloc_funcIN5realm5_impl17DeepChangeCheckerENS_9allocatorIS4_EEFbxEEclEOx + 50
15  App                        0x0000000109ed5803 _ZNSt3__110__function6__funcIN5realm5_impl17DeepChangeCheckerENS_9allocatorIS4_EEFbxEEclEOx + 51
16  App                        0x0000000109eb12dd _ZNKSt3__110__function12__value_funcIFbxEEclEOx + 77
17  App                        0x0000000109eaf5a0 _ZNKSt3__18functionIFbxEEclEx + 48
18  App                        0x0000000109eaae82 _ZN12_GLOBAL__N_19calculateERN5realm5_impl23CollectionChangeBuilderENSt3__16vectorINS_7RowInfoENS4_9allocatorIS6_EEEES9_NS4_8functionIFbxEEEb + 930
19  App                        0x0000000109eaa98c _ZN5realm5_impl23CollectionChangeBuilder9calculateERKNSt3__16vectorIxNS2_9allocatorIxEEEES8_NS2_8functionIFbxEEEb + 460
20  App                        0x000000010a183bf4 _ZN5realm5_impl15ResultsNotifier17calculate_changesEv + 580
21  App                        0x000000010a18431a _ZN5realm5_impl15ResultsNotifier3runEv + 842
22  App                        0x000000010a0ed0f9 _ZN5realm5_impl16RealmCoordinator19run_async_notifiersEv + 4281
23  App                        0x000000010a0ebf0c _ZN5realm5_impl16RealmCoordinator9on_changeEv + 28
24  App                        0x0000000109ee953f _ZN5realm5_impl20ExternalCommitHelper6listenEv + 767
25  App                        0x0000000109eeccd8 _ZZN5realm5_impl20ExternalCommitHelperC1ERNS0_16RealmCoordinatorEENK3$_0clEv + 24
26  App                        0x0000000109eecc6d _ZNSt3__1L8__invokeIZN5realm5_impl20ExternalCommitHelperC1ERNS2_16RealmCoordinatorEE3$_0JEEEDTclclsr3std3__1E7forwardIT_Efp_Espclsr3std3__1E7forwardIT0_Efp0_EEEOS7_DpOS8_ + 29
27  App                        0x0000000109eecbd5 _ZNSt3__1L16__thread_executeINS_10unique_ptrINS_15__thread_structENS_14default_deleteIS2_EEEEZN5realm5_impl20ExternalCommitHelperC1ERNS7_16RealmCoordinatorEE3$_0JEJEEEvRNS_5tupleIJT_T0_DpT1_EEENS_15__tuple_indicesIJXspT2_EEEE + 37
28  App                        0x0000000109eec456 _ZNSt3__1L14__thread_proxyINS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEEZN5realm5_impl20ExternalCommitHelperC1ERNS8_16RealmCoordinatorEE3$_0EEEEEPvSE_ + 118
29  libsystem_pthread.dylib             0x00007fff61167109 _pthread_start + 148
30  libsystem_pthread.dylib             0x00007fff61162b8b thread_start + 15!!! IMPORTANT: Please send this log and info about Realm SDK version and other relevant reproduction info to [email protected] 14:37:46.522084+0200 App[75154:442417] /Replaced/node_modules/realm/vendor/realm-ios/include/realm/table.hpp:251: [realm-core-10.1.4] Assertion failed: !key.is_unresolved()
0   App                        0x000000010a9c4a8c _ZN5realm4utilL18terminate_internalERNSt3__118basic_stringstreamIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 28
1   App                        0x000000010a9c4d7b _ZN5realm4util9terminateEPKcS2_lOSt16initializer_listINS0_9PrintableEE + 395
2   App                        0x0000000109ec55ea _ZNK5realm5Table10get_objectENS_6ObjKeyE + 122
3   App                        0x0000000109ec523f _ZN5realm5_impl17DeepChangeChecker20check_outgoing_linksENS_8TableKeyERKNS_5TableExm + 303
4   App                        0x0000000109ec58f8 _ZN5realm5_impl17DeepChangeChecker9check_rowERKNS_5TableExm + 488
5   App                        0x0000000109edfb44 _ZZZN5realm5_impl17DeepChangeChecker20check_outgoing_linksENS_8TableKeyERKNS_5TableExmENK3$_7clERKNS1_12OutgoingLinkEENKUlT_E_clINS_6ObjKeyEEEDaSA_ + 52
6   App                        0x0000000109ede147 _ZNSt3__1L6any_ofIN5realm11LstIteratorINS1_6ObjKeyEEEZZNS1_5_impl17DeepChangeChecker20check_outgoing_linksENS1_8TableKeyERKNS1_5TableExmENK3$_7clERKNS6_12OutgoingLinkEEUlT_E_EEbSF_SF_T0_ + 87
7   App                        0x0000000109edde79 _ZZN5realm5_impl17DeepChangeChecker20check_outgoing_linksENS_8TableKeyERKNS_5TableExmENK3$_7clERKNS1_12OutgoingLinkE + 713
8   App                        0x0000000109ec5667 _ZNSt3__1L6any_ofINS_11__wrap_iterIPKN5realm5_impl17DeepChangeChecker12OutgoingLinkEEEZNS4_20check_outgoing_linksENS2_8TableKeyERKNS2_5TableExmE3$_7EEbT_SE_T0_ + 71
9   App                        0x0000000109ec536f _ZN5realm5_impl17DeepChangeChecker20check_outgoing_linksENS_8TableKeyERKNS_5TableExm + 607
10  App                        0x0000000109ec58f8 _ZN5realm5_impl17DeepChangeChecker9check_rowERKNS_5TableExm + 488
11  App                        0x0000000109ec5bc3 _ZN5realm5_impl17DeepChangeCheckerclEx + 99
12  App                        0x0000000109edb1e2 _ZNSt3__1L8__invokeIRN5realm5_impl17DeepChangeCheckerEJxEEEDTclclsr3std3__1E7forwardIT_Efp_Espclsr3std3__1E7forwardIT0_Efp0_EEEOS5_DpOS6_ + 50
13  App                        0x0000000109edb182 _ZNSt3__128__invoke_void_return_wrapperIbE6__callIJRN5realm5_impl17DeepChangeCheckerExEEEbDpOT_ + 50
14  App                        0x0000000109edb142 _ZNSt3__110__function12__alloc_funcIN5realm5_impl17DeepChangeCheckerENS_9allocatorIS4_EEFbxEEclEOx + 50
15  App                        0x0000000109ed5803 _ZNSt3__110__function6__funcIN5realm5_impl17DeepChangeCheckerENS_9allocatorIS4_EEFbxEEclEOx + 51
16  App                        0x0000000109eb12dd _ZNKSt3__110__function12__value_funcIFbxEEclEOx + 77
17  App                        0x0000000109eaf5a0 _ZNKSt3__18functionIFbxEEclEx + 48
18  App                        0x0000000109eaae82 _ZN12_GLOBAL__N_19calculateERN5realm5_impl23CollectionChangeBuilderENSt3__16vectorINS_7RowInfoENS4_9allocatorIS6_EEEES9_NS4_8functionIFbxEEEb + 930
19  App                        0x0000000109eaa98c _ZN5realm5_impl23CollectionChangeBuilder9calculateERKNSt3__16vectorIxNS2_9allocatorIxEEEES8_NS2_8functionIFbxEEEb + 460
20  App                        0x000000010a183bf4 _ZN5realm5_impl15ResultsNotifier17calculate_changesEv + 580
21  App                        0x000000010a18431a _ZN5realm5_impl15ResultsNotifier3runEv + 842
22  App                        0x000000010a0ed0f9 _ZN5realm5_impl16RealmCoordinator19run_async_notifiersEv + 4281
23  App                        0x000000010a0ebf0c _ZN5realm5_impl16RealmCoordinator9on_changeEv + 28
24  App                        0x0000000109ee953f _ZN5realm5_impl20ExternalCommitHelper6listenEv + 767
25  App                        0x0000000109eeccd8 _ZZN5realm5_impl20ExternalCommitHelperC1ERNS0_16RealmCoordinatorEENK3$_0clEv + 24
26  App                        0x0000000109eecc6d _ZNSt3__1L8__invokeIZN5realm5_impl20ExternalCommitHelperC1ERNS2_16RealmCoordinatorEE3$_0JEEEDTclclsr3std3__1E7forwardIT_Efp_Espclsr3std3__1E7forwardIT0_Efp0_EEEOS7_DpOS8_ + 29
27  App                        0x0000000109eecbd5 _ZNSt3__1L16__thread_executeINS_10unique_ptrINS_15__thread_structENS_14default_deleteIS2_EEEEZN5realm5_impl20ExternalCommitHelperC1ERNS7_16RealmCoordinatorEE3$_0JEJEEEvRNS_5tupleIJT_T0_DpT1_EEENS_15__tuple_indicesIJXspT2_EEEE + 37
28  App                        0x0000000109eec456 _ZNSt3__1L14__thread_proxyINS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEEZN5realm5_impl20ExternalCommitHelperC1ERNS8_16RealmCoordinatorEE3$_0EEEEEPvSE_ + 118
29  libsystem_pthread.dylib             0x00007fff61167109 _pthread_start + 148
30  libsystem_pthread.dylib             0x00007fff61162b8b thread_start + 15!!! IMPORTANT: Please send this log and info about Realm SDK version and other relevant reproduction info to [email protected].
CoreSimulator 732.18.6 - Device: iPhone SE (2nd generation) (9322FDCE-121C-4666-99F0-86A37BB1FF9F) - Runtime: iOS 14.4 (18D46) - DeviceType: iPhone SE (2nd generation)
(lldb)

Steps to Reproduce

I think it was either from collection listener or filter query. Happened only once. I'm still trying to reproduce it.

Version of Realm and Tooling

Realm JS SDK - 10.2.0
React Native - 0.63.4
OS: MacOS Catalina 10.15.7
Client OS & Version: iPhone SE 2 Simulator iOS 14.4

@RosenTomov
Copy link
Author

Seems to be related to the collection listener. It executes the first time and crashes on subsequent triggers.

realm.objects('Test').addListener(() => { console.log('test'); });

@kneth
Copy link
Contributor

kneth commented Mar 1, 2021

@RosenTomov Thank you for the bug report.

Do you only observe it on iOS?

We have recently fixed a couple of logic errors in the notification system and we will try to see if your crash is related.

@RosenTomov
Copy link
Author

Hello @kneth, the error was caused by a reference to a non-existent object.

ex:

Vehicles: ['1', '2', 'id to non-existent object']

It's been working fine since we removed the id. We didn't get to test it on android.
It was also working fine on our node server before and after removing the referenced id, no errors or anything.

@kneth
Copy link
Contributor

kneth commented Mar 1, 2021

You shouldn't see a native crash but a JavaScript exception might be fine.

@euZebe
Copy link

euZebe commented Mar 3, 2021

I get the same error, and can reproduce it on demand. The strange thing to me is that it happens when updating a value. I suppose the object still exists ; it is just mutated.

@kraenhansen
Copy link
Member

kraenhansen commented Mar 3, 2021

@euZebe great! Would you mind putting together a small project / guide on how to reproduce it?
In particular, we're interested in knowing:

  • What versions are you using?
  • What steps are you taking?
  • What code triggers the error and what schema is the app using?

@euZebe
Copy link

euZebe commented Mar 3, 2021

That's non straight forward since it is an existing project I have just started on. I'll do my best.
Right now, I can tell you

  • it happens on both versions 10.1.0 and 10.2.0
  • I am on a form, I update the object with
      realm?.write(() => {
        for (const key in updatedValues) {
          if (updatedValues.hasOwnProperty(key)) {
            const val = updatedValues[key];
            patient[key] = typeof val === 'string' ? val?.trim() : val;
          }
        }
      });

The data is updated successfully, but I have not yet located exactly where the error is occuring.

@euZebe
Copy link

euZebe commented Mar 4, 2021

I went a bit further in the issue: I have a screen with two tabs, one for a patient form (which I can edit) and the other with acts related to this patient. When updating the patient from the form, the app closes and I get the above error.

Here is a piece of code which produces the error:
The Acts tab uses a useActMetadata() hook containing that kind of code:

  useEffect(() => {
    const syncActMetadata = realm.objects<RealmActMetadata>(
      RealmActMetadata.schema.name,
    );
    syncRefByPatient.current = syncActMetadata;

    syncActMetadata.addListener((items, changes) => {   // <== Note: commenting this prevents from crashing
      if (
        changes.deletions.length ||
        changes.insertions.length ||
        changes.newModifications.length
      ) {
        setLastUpdate(new Date());
      }
    });
    setLastUpdate(new Date());

    return () => syncActMetadata.removeAllListeners();
  }, [realm]);

Remarks:

  • When commenting the .addListener(), updating the patient doesn't provoke a crash.
  • When putting a ref on another collection, Act (which has the same relationship with the Patient object) instead of ActMetadata, no crash happen.

I tried to reproduce it in a simple example but I did not manage to get the error yet.

@sync-by-unito sync-by-unito bot changed the title Crash report from React Native Crash in table.hpp:251: [realm-core-10.1.4] Assertion failed: !key.is_unresolved() Mar 26, 2021
@julien100
Copy link

I have the exact same issue. If I do an update with

await realm.write(() => { realm.create(Example.schema.name, task, Realm.UpdateMode.Modified); });

and I have an active listener, then my whole app crashes, but change is written.

@kneth
Copy link
Contributor

kneth commented Apr 9, 2021

@euZebe Does setLastUpdate() execute a Realm write transaction? If so, your listener might be result in a new call to the listener while still in a write transaction. It shouldn't give you a C++ error but a JavaScript exception.

@ironage
Copy link
Contributor

ironage commented Apr 9, 2021

This issue appears to be related to realm/realm-core#4175 and should be fixed in realm-js 10.3.0 or later (the core monorepo releases).

@kneth
Copy link
Contributor

kneth commented Apr 12, 2021

@euZebe Please try to upgrade to v10.3.0.

@RosenTomov
Copy link
Author

We tested it again by manually setting a reference to a non-existent object, now crashes the app and throws the following:

2021-04-20 08:33:13.921467+0300 App[73239:3204065] uncaught exception in notifier thread: N5realm11KeyNotFoundE: No such object
libc++abi.dylib: terminating with uncaught exception of type realm::KeyNotFound: No such object
terminating with uncaught exception of type realm::KeyNotFound: No such object

instead of the original error.

iPhone SE Simulator - iOS 14.4
Mac Mini 2018 - Mac OS Catalina 10.15.7
react-native version - 0.63.4
realm version - 10.4.0

@ironage
Copy link
Contributor

ironage commented Apr 21, 2021

Hey @RosenTomov thanks for the update, glad to hear the assertion is fixed.
How/where are you manually setting a reference to a non-existent object? This should not happen in the change listener anymore, so I would like to think that the issue is fixed and the behaviour you observe is related to the way you are manually changing things (through the debugger?). Unless you can provide more information about the the way you are testing and still believe it is a real issue, or this is something you have observed in production?

@kneth
Copy link
Contributor

kneth commented May 13, 2021

Realm JavaScript v10.4.1 has the fixed mentioned above. I am closing the issue, and if you continue to observe the crash, please create a new issue.

@kneth kneth closed this as completed May 13, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants