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

Calling foundSubscription.updateQuery throws unhandled exception #7836

Closed
ScottThomasMiller opened this issue Jun 24, 2024 · 5 comments · Fixed by #8010
Closed

Calling foundSubscription.updateQuery throws unhandled exception #7836

ScottThomasMiller opened this issue Jun 24, 2024 · 5 comments · Fixed by #8010

Comments

@ScottThomasMiller
Copy link

SDK and version

SDK : RealmSwift (Cocoa, Java, etc)
Version: Realm 10.52.0, RealmDatabase 14.10.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? Yes: build and run the attached project in Xcode, for the iPhone target.

Crash log / stacktrace

Info: Realm sync client ([realm-core-14.10.1])
Info: Platform: iOS Darwin 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:34:02 PDT 2024; root:xnu-10063.122.3~3/RELEASE_ARM64_T8120 iPhone15,2
Info: Connection[1] Session[1]: Binding '/var/mobile/Containers/Data/Application/0B6417E2-3CD3-4CD8-B712-B94E381569E2/Documents/mongodb-realm/share-zjugltx/66730f022150f0e2467d69f5/flx_sync_default.realm' to ''
Info: Connection[1] Session[1]: client_reset_config = false, Realm exists = true
Info: Connection[1] Connecting to 'wss://ws.services.cloud.mongodb.com:443/api/client/v2.0/app/share-zjugltx/realm-sync'
Info: Connection[1] Connect timeout
To view your data in Atlas, go to this link: https://cloud.mongodb.com/links/651b55381a71d124d96f7cde/explorer/Cluster0/database/collection/find
Info: Connection[1] Connecting to 'wss://ws.services.cloud.mongodb.com:443/api/client/v2.0/app/share-zjugltx/realm-sync'
Info: Connected to endpoint '3.211.22.90:443' (from '192.168.1.29:57649')
Info: Connection[1] Connected to app services with request id: "6678b98864e6a1423c0b4375"
Info: Connection[2] Session[2]: Binding '/var/mobile/Containers/Data/Application/0B6417E2-3CD3-4CD8-B712-B94E381569E2/Documents/mongodb-realm/share-zjugltx/66730f022150f0e2467d69f5/flx_sync_default.realm' to ''
Info: Connection[2] Session[2]: client_reset_config = false, Realm exists = true
Info: Connection[2] Connecting to 'wss://us-east-1.aws.ws.services.cloud.mongodb.com:443/api/client/v2.0/app/share-zjugltx/realm-sync'
Info: Connected to endpoint '107.20.72.25:443' (from '192.168.1.29:57650')
Info: Connection[2] Connected to app services with request id: "6678b98864e6a1423c0b7fb4"
found subscription for myPosts
/Users/scottmiller/Library/Developer/Xcode/DerivedData/App-fllwbzcoarmiwbabgmqoxitzmcze/SourcePackages/checkouts/realm-core/src/realm/exceptions.cpp:80: [realm-core-14.10.1] Unreachable code
0 RealmSwift 0x0000000109786504 _ZN5realm4utilL18terminate_internalERNSt3__118basic_stringstreamIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 28
1 RealmSwift 0x00000001097864e4 _ZN5realm4util19terminate_with_infoEPKcS2_lS2_OSt16initializer_listINS0_9PrintableEE + 308
2 RealmSwift 0x00000001097863b0 _ZN5realm4util19terminate_with_infoEPKcS2_lS2_OSt16initializer_listINS0_9PrintableEE + 0
3 RealmSwift 0x000000010902bf04 _ZN5realm19exception_to_statusEv + 304
4 RealmSwift 0x000000010931afd4 _ZN5realm13AsyncOpenTask30wait_for_bootstrap_or_completeEONS_4util14UniqueFunctionIFvNS_19ThreadSafeReferenceESt13exception_ptrEEENSt3__110shared_ptrINS_5_impl16RealmCoordinatorEEENS_6StatusE + 596
5 RealmSwift 0x000000010931b90c _ZN5realm13AsyncOpenTask26migrate_schema_or_completeEONS_4util14UniqueFunctionIFvNS_19ThreadSafeReferenceESt13exception_ptrEEENSt3__110shared_ptrINS_5_impl16RealmCoordinatorEEE + 224
6 RealmSwift 0x000000010931dda0 _ZZN5realm13AsyncOpenTask5startENS_4util14UniqueFunctionIFvNS_19ThreadSafeReferenceESt13exception_ptrEEEEN3$_0clENS_6StatusE + 380
7 RealmSwift 0x000000010931dadc _ZN5realm4util14UniqueFunctionIFvNS_6StatusEEE12SpecificImplIZNS_13AsyncOpenTask5startENS1_IFvNS_19ThreadSafeReferenceESt13exception_ptrEEEE3$0E4callEOS2 + 60
8 RealmSwift 0x0000000109353d68 ZNK5realm4util14UniqueFunctionIFvNS_6StatusEEEclES2 + 112
9 RealmSwift 0x0000000109377f74 _ZZN5realm11SyncSession23add_completion_callbackENS_4util14UniqueFunctionIFvNS_6StatusEEEENS_5_impl20SyncProgressNotifier12NotifierTypeEENK4$12clES3 + 224
10 RealmSwift 0x0000000109377dd4 _ZN5realm4util14UniqueFunctionIFvNS_6StatusEEE12SpecificImplIZNS_11SyncSession23add_completion_callbackES4_NS_5_impl20SyncProgressNotifier12NotifierTypeEE4$12E4callEOS2 + 60
11 RealmSwift 0x0000000109353d68 ZNK5realm4util14UniqueFunctionIFvNS_6StatusEEEclES2 + 112
12 RealmSwift 0x000000010951dd18 _ZN5realm4sync14SessionWrapper22on_download_completionEv + 112
13 RealmSwift 0x000000010951dc98 _ZN5realm4sync10ClientImpl7Session22on_download_completionEv + 56
14 RealmSwift 0x0000000109601d8c _ZN5realm4sync10ClientImpl7Session29check_for_download_completionEv + 304
15 RealmSwift 0x00000001095ff860 _ZN5realm4sync10ClientImpl7Session20receive_mark_messageEy + 416
16 RealmSwift 0x00000001095ff644 _ZN5realm4sync10ClientImpl10Connection20receive_mark_messageEyy + 124
17 RealmSwift 0x00000001095fc614 _ZN5realm5_impl14ClientProtocol22parse_message_receivedINS_4sync10ClientImpl10ConnectionEEEvRT_NSt3__117basic_string_viewIcNS8_11char_traitsIcEEEE + 4388
18 RealmSwift 0x00000001095f821c _ZN5realm4sync10ClientImpl10Connection23handle_message_receivedENS_4util4SpanIKcLm18446744073709551615EEE + 112
19 RealmSwift 0x00000001095f8104 _ZN5realm4sync10ClientImpl10Connection33websocket_binary_message_receivedENS_4util4SpanIKcLm18446744073709551615EEE + 252
20 RealmSwift 0x0000000109613558 _ZN5realm4sync10ClientImpl10Connection21WebSocketObserverShim33websocket_binary_message_receivedENS_4util4SpanIKcLm18446744073709551615EEE + 100
21 RealmSwift 0x000000010957455c _ZN5realm4sync9websocket12_GLOBAL__N_120DefaultWebSocketImpl33websocket_binary_message_receivedEPKcm + 80
22 RealmSwift 0x00000001095ab5d0 _ZN12_GLOBAL__N_19WebSocket17frame_reader_loopEv + 232
23 RealmSwift 0x00000001095ad094 _ZZN12_GLOBAL__N_19WebSocket17frame_reader_loopEvENKUlNSt3__110error_codeEmE_clES2_m + 180
24 RealmSwift 0x00000001095acfa8 _ZN5realm4util14UniqueFunctionIFvNSt3__110error_codeEmEE12SpecificImplIZN12_GLOBAL__N_19WebSocket17frame_reader_loopEvEUlS3_mE_E4callEOS3_Om + 64
25 RealmSwift 0x0000000109586df4 _ZNK5realm4util14UniqueFunctionIFvNSt3__110error_codeEmEEclES3_m + 120
26 RealmSwift 0x0000000109586b68 ZN5realm4sync7network7Service9AsyncOper29do_recycle_and_execute_helperINS_4util14UniqueFunctionIFvNSt3__110error_codeEmEEEJS8_mEEEvbRbT_DpT0 + 108
27 RealmSwift 0x0000000109586a80 ZN5realm4sync7network7Service9AsyncOper22do_recycle_and_executeINS_4util14UniqueFunctionIFvNSt3__110error_codeEmEEEJRS8_RmEEEvbRT_DpOT0 + 168
28 RealmSwift 0x00000001095864c4 _ZN5realm4sync7network7Service14BasicStreamOpsINS1_3ssl6StreamEE16BufferedReadOperINS_4util14UniqueFunctionIFvNSt3__110error_codeEmEEEE19recycle_and_executeEv + 656
29 RealmSwift 0x0000000109598134 _ZN5realm4sync7network7Service4Impl7executeERNSt3__110unique_ptrINS2_9AsyncOperENS2_18LendersOperDeleterEEE + 36
30 RealmSwift 0x0000000109597e40 _ZN5realm4sync7network7Service4Impl8run_implEb + 320
31 RealmSwift 0x0000000109593c28 _ZN5realm4sync7network7Service4Impl17run_until_stoppedEv + 32
32 RealmSwift 0x0000000109593bfc _ZN5realm4sync7network7Service17run_until_stoppedEv + 28
33 RealmSwift 0x000000010956da84 _ZN5realm4sync9websocket21DefaultSocketProvider10event_loopEv + 352
34 RealmSwift 0x00000001095721fc ZNSt3__18__invokeB8ue170006IMN5realm4sync9websocket21DefaultSocketProviderEFvvEPS4_JEvEEDTcldsdeclsr3stdE7declvalIT0_EEclsr3stdE7declvalIT_EEspclsr3stdE7declvalIT1_EEEEOS9_OS8_DpOSA + 116
35 RealmSwift 0x000000010957217c _ZNSt3__116__thread_executeB8ue170006INS_10unique_ptrINS_15__thread_structENS_14default_deleteIS2_EEEEMN5realm4sync9websocket21DefaultSocketProviderEFvvEJPS9_EJLm2EEEEvRNS_5tupleIJT_T0_DpT1_EEENS_15__tuple_indicesIJXspT2_EEEE + 48
36 RealmSwift 0x0000000109571e28 ZNSt3__114__thread_proxyB8ue170006INS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEEMN5realm4sync9websocket21DefaultSocketProviderEFvvEPSA_EEEEEPvSF + 84
37 libsystem_pthread.dylib 0x00000001e7f2d06c _pthread_start + 136
38 libsystem_pthread.dylib 0x00000001e7f280d8 thread_start + 8
!!! IMPORTANT: Please report this at https://github.com/realm/realm-core/issues/new/choose
/Users/scottmiller/Library/Developer/Xcode/DerivedData/App-fllwbzcoarmiwbabgmqoxitzmcze/SourcePackages/checkouts/realm-core/src/realm/exceptions.cpp:80: [realm-core-14.10.1] Unreachable code
0 RealmSwift 0x0000000109786504 _ZN5realm4utilL18terminate_internalERNSt3__118basic_stringstreamIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 28
1 RealmSwift 0x00000001097864e4 _ZN5realm4util19terminate_with_infoEPKcS2_lS2_OSt16initializer_listINS0_9PrintableEE + 308
2 RealmSwift 0x00000001097863b0 _ZN5realm4util19terminate_with_infoEPKcS2_lS2_OSt16initializer_listINS0_9PrintableEE + 0
3 RealmSwift 0x000000010902bf04 _ZN5realm19exception_to_statusEv + 304
4 RealmSwift 0x000000010931afd4 _ZN5realm13AsyncOpenTask30wait_for_bootstrap_or_completeEONS_4util14UniqueFunctionIFvNS_19ThreadSafeReferenceESt13exception_ptrEEENSt3__110shared_ptrINS_5_impl16RealmCoordinatorEEENS_6StatusE + 596
5 RealmSwift 0x000000010931b90c _ZN5realm13AsyncOpenTask26migrate_schema_or_completeEONS_4util14UniqueFunctionIFvNS_19ThreadSafeReferenceESt13exception_ptrEEENSt3__110shared_ptrINS_5_impl16RealmCoordinatorEEE + 224
6 RealmSwift 0x000000010931dda0 _ZZN5realm13AsyncOpenTask5startENS_4util14UniqueFunctionIFvNS_19ThreadSafeReferenceESt13exception_ptrEEEEN3$_0clENS_6StatusE + 380
7 RealmSwift 0x000000010931dadc _ZN5realm4util14UniqueFunctionIFvNS_6StatusEEE12SpecificImplIZNS_13AsyncOpenTask5startENS1_IFvNS_19ThreadSafeReferenceESt13exception_ptrEEEE3$0E4callEOS2 + 60
8 RealmSwift 0x0000000109353d68 ZNK5realm4util14UniqueFunctionIFvNS_6StatusEEEclES2 + 112
9 RealmSwift 0x0000000109377f74 _ZZN5realm11SyncSession23add_completion_callbackENS_4util14UniqueFunctionIFvNS_6StatusEEEENS_5_impl20SyncProgressNotifier12NotifierTypeEENK4$12clES3 + 224
10 RealmSwift 0x0000000109377dd4 _ZN5realm4util14UniqueFunctionIFvNS_6StatusEEE12SpecificImplIZNS_11SyncSession23add_completion_callbackES4_NS_5_impl20SyncProgressNotifier12NotifierTypeEE4$12E4callEOS2 + 60
11 RealmSwift 0x0000000109353d68 ZNK5realm4util14UniqueFunctionIFvNS_6StatusEEEclES2 + 112
12 RealmSwift 0x000000010951dd18 _ZN5realm4sync14SessionWrapper22on_download_completionEv + 112
13 RealmSwift 0x000000010951dc98 _ZN5realm4sync10ClientImpl7Session22on_download_completionEv + 56
14 RealmSwift 0x0000000109601d8c _ZN5realm4sync10ClientImpl7Session29check_for_download_completionEv + 304
15 RealmSwift 0x00000001095ff860 _ZN5realm4sync10ClientImpl7Session20receive_mark_messageEy + 416
16 RealmSwift 0x00000001095ff644 _ZN5realm4sync10ClientImpl10Connection20receive_mark_messageEyy + 124
17 RealmSwift 0x00000001095fc614 _ZN5realm5_impl14ClientProtocol22parse_message_receivedINS_4sync10ClientImpl10ConnectionEEEvRT_NSt3__117basic_string_viewIcNS8_11char_traitsIcEEEE + 4388
18 RealmSwift 0x00000001095f821c _ZN5realm4sync10ClientImpl10Connection23handle_message_receivedENS_4util4SpanIKcLm18446744073709551615EEE + 112
19 RealmSwift 0x00000001095f8104 _ZN5realm4sync10ClientImpl10Connection33websocket_binary_message_receivedENS_4util4SpanIKcLm18446744073709551615EEE + 252
20 RealmSwift 0x0000000109613558 _ZN5realm4sync10ClientImpl10Connection21WebSocketObserverShim33websocket_binary_message_receivedENS_4util4SpanIKcLm18446744073709551615EEE + 100
21 RealmSwift 0x000000010957455c _ZN5realm4sync9websocket12_GLOBAL__N_120DefaultWebSocketImpl33websocket_binary_message_receivedEPKcm + 80
22 RealmSwift 0x00000001095ab5d0 _ZN12_GLOBAL__N_19WebSocket17frame_reader_loopEv + 232
23 RealmSwift 0x00000001095ad094 _ZZN12_GLOBAL__N_19WebSocket17frame_reader_loopEvENKUlNSt3__110error_codeEmE_clES2_m + 180
24 RealmSwift 0x00000001095acfa8 _ZN5realm4util14UniqueFunctionIFvNSt3__110error_codeEmEE12SpecificImplIZN12_GLOBAL__N_19WebSocket17frame_reader_loopEvEUlS3_mE_E4callEOS3_Om + 64
25 RealmSwift 0x0000000109586df4 _ZNK5realm4util14UniqueFunctionIFvNSt3__110error_codeEmEEclES3_m + 120
26 RealmSwift 0x0000000109586b68 ZN5realm4sync7network7Service9AsyncOper29do_recycle_and_execute_helperINS_4util14UniqueFunctionIFvNSt3__110error_codeEmEEEJS8_mEEEvbRbT_DpT0 + 108
27 RealmSwift 0x0000000109586a80 ZN5realm4sync7network7Service9AsyncOper22do_recycle_and_executeINS_4util14UniqueFunctionIFvNSt3__110error_codeEmEEEJRS8_RmEEEvbRT_DpOT0 + 168
28 RealmSwift 0x00000001095864c4 _ZN5realm4sync7network7Service14BasicStreamOpsINS1_3ssl6StreamEE16BufferedReadOperINS_4util14UniqueFunctionIFvNSt3__110error_codeEmEEEE19recycle_and_executeEv + 656
29 RealmSwift 0x0000000109598134 _ZN5realm4sync7network7Service4Impl7executeERNSt3__110unique_ptrINS2_9AsyncOperENS2_18LendersOperDeleterEEE + 36
30 RealmSwift 0x0000000109597e40 _ZN5realm4sync7network7Service4Impl8run_implEb + 320
31 RealmSwift 0x0000000109593c28 _ZN5realm4sync7network7Service4Impl17run_until_stoppedEv + 32
32 RealmSwift 0x0000000109593bfc _ZN5realm4sync7network7Service17run_until_stoppedEv + 28
33 RealmSwift 0x000000010956da84 _ZN5realm4sync9websocket21DefaultSocketProvider10event_loopEv + 352
34 RealmSwift 0x00000001095721fc ZNSt3__18__invokeB8ue170006IMN5realm4sync9websocket21DefaultSocketProviderEFvvEPS4_JEvEEDTcldsdeclsr3stdE7declvalIT0_EEclsr3stdE7declvalIT_EEspclsr3stdE7declvalIT1_EEEEOS9_OS8_DpOSA + 116
35 RealmSwift 0x000000010957217c _ZNSt3__116__thread_executeB8ue170006INS_10unique_ptrINS_15__thread_structENS_14default_deleteIS2_EEEEMN5realm4sync9websocket21DefaultSocketProviderEFvvEJPS9_EJLm2EEEEvRNS_5tupleIJT_T0_DpT1_EEENS_15__tuple_indicesIJXspT2_EEEE + 48
36 RealmSwift 0x0000000109571e28 ZNSt3__114__thread_proxyB8ue170006INS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEEMN5realm4sync9websocket21DefaultSocketProviderEFvvEPSA_EEEEEPvSF + 84
37 libsystem_pthread.dylib 0x00000001e7f2d06c _pthread_start + 136
38 libsystem_pthread.dylib 0x00000001e7f280d8 thread_start + 8
!!! IMPORTANT: Please report this at https://github.com/realm/realm-core/issues/new/choose
Message from debugger: killed

Steps & Code to Reproduce

The error happens in ContentView when it calls foundSubscription.updateQuery. I will upload the zipped project. It's basically the to-do list template but with a different object type.
Share_client_20240619165748.zip

I am building and running for iPhone 14.

Copy link

sync-by-unito bot commented Jun 24, 2024

➤ PM Bot commented:

Jira ticket: RCORE-2180

@ScottThomasMiller
Copy link
Author

I logged out of the app, and then created a new user account and logged in with the new account. The exception did not reoccur. I then logged out of the app again and logged in as the first user, and again the error did not reoccur.

It might have something to do with a bug in my code. In OpenRealmView() I had forgotten to change the onChange(of: showMyPosts) closure, to replace Constants.allItems with Contants.allPosts. After fixing the bug the closure now reads:

                .onChange(of: showMyPosts) { newValue in
                    let subs = realm.subscriptions
                    subs.update {
                        if newValue {
                            subs.remove(named: Constants.allPosts)
                        } else {
                            if subs.first(named: Constants.allPosts) == nil {
                                subs.append(QuerySubscription<Post>(name: Constants.allPosts))
                            }
                        }
                    }
                }

@ironage
Copy link
Contributor

ironage commented Jul 4, 2024

@ScottThomasMiller thanks for reporting this. We have seen a similar case in #7798 where the exception being thrown comes from a callback in obj-c and our C++ exception handling doesn't yet support handling this. As you found out, it is likely due to a schema error; but it shouldn't be causing such a hard stop. Glad you figured out the bug on your end. For others who are experiencing this, please set an obj-c exception breakpoint in your debugger to inspect the error message of the cause, until we can add the appropriate error handling translation of a NSException in C++.

@ironage
Copy link
Contributor

ironage commented Jul 4, 2024

Internal team context for an approach to the solution from execption_to_status
tgoyne: I think for ideal handling of this we want core to define a NSException subclass which holds a Status?
so that cocoa can try to preserve the original Status and have it round-trip properly

@jedelbo
Copy link
Contributor

jedelbo commented Aug 14, 2024

@tgoyne ^

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 29, 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.

3 participants