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

Unity editor crashes when leaving play mode during async operation #2800

Closed
nirinchev opened this issue Feb 1, 2022 · 2 comments
Closed
Assignees
Labels

Comments

@nirinchev
Copy link
Member

Reported on the forums:

The Unity Editor is crashing very often after leaving the Play mode. This is happening with my game project after I added Realm and also with a small test project that uses only the few most important functions (authentication, connecting to realm, starting sync). I tried with the recommended Unity version 2020.3.12 as well as the latest version. It’s always the same problem.
It crashes also sometimes when just clicking back into the Unity Editor after a few minutes of inactivity.
This makes Realm almost unusuable in my main project as it takes a long time to startup due to enabled collaboration.
Fixing these crashes in the Unity Editor should be the top priority for the .NET API!

And here are the stacktraces:

Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) Realms.Sync.SessionHandle/NativeMethods.destroy (intptr) [0x00009] in <4588409fe1d84ee9b4108329f1189e94>:0
  at Realms.Sync.SessionHandle.Unbind () [0x00006] in <4588409fe1d84ee9b4108329f1189e94>:0
  at Realms.RealmHandle.RequestUnbind (Realms.RealmHandle) [0x00020] in <4588409fe1d84ee9b4108329f1189e94>:0
  at Realms.RealmHandle.ReleaseHandle () [0x0002d] in <4588409fe1d84ee9b4108329f1189e94>:0
  at System.Runtime.InteropServices.SafeHandle.DangerousReleaseInternal (bool) [0x000a4] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Runtime.InteropServices.SafeHandle.InternalFinalize () [0x0000a] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Runtime.InteropServices.SafeHandle.Dispose (bool) [0x0000b] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Runtime.InteropServices.SafeHandle.Finalize () [0x00002] in <695d1cc93cca45069c528c15c9fdd749>:0
  at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) [0x00020] in <695d1cc93cca45069c528c15c9fdd749>:0

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

Unloading 0 Unused Serialized files (Serialized files now loaded: 0)
Crash!!!
Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) Realms.Native.HttpClientTransport.respond (Realms.Native.HttpClientTransport/HttpClientResponse,Realms.Sync.Native.StringStringPair[],int,intptr) [0x0010c] in <4588409fe1d84ee9b4108329f1189e94>:0
  at Realms.Native.HttpClientTransport/<ExecuteRequest>d__9.MoveNext () [0x00335] in <4588409fe1d84ee9b4108329f1189e94>:0
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner.InvokeMoveNext (object) [0x00006] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00073] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00004] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner.Run () [0x00032] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action,bool,System.Threading.Tasks.Task&) [0x0001d] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Threading.Tasks.Task.FinishContinuations () [0x0006f] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Threading.Tasks.Task.FinishStageThree () [0x0003d] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Threading.Tasks.Task`1<TResult_REF>.TrySetResult (TResult_REF) [0x00050] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<TResult_REF>.SetResult (TResult_REF) [0x00040] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Net.Http.HttpClient/<SendAsyncWorker>d__47.MoveNext () [0x001e6] in <a1ea9757398742d6979db7cbaf288344>:0
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner.InvokeMoveNext (object) [0x00006] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00073] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00004] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner.Run () [0x00032] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action,bool,System.Threading.Tasks.Task&) [0x0001d] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Threading.Tasks.Task.FinishContinuations () [0x0006f] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Threading.Tasks.Task.FinishStageThree () [0x0003d] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Threading.Tasks.Task`1<TResult_REF>.TrySetResult (TResult_REF) [0x00050] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<TResult_REF>.SetResult (TResult_REF) [0x00040] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Net.Http.HttpClientHandler/<SendAsync>d__65.MoveNext () [0x00542] in <a1ea9757398742d6979db7cbaf288344>:0
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner.InvokeMoveNext (object) [0x00006] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00073] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00004] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner.Run () [0x00032] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action,bool,System.Threading.Tasks.Task&) [0x0001d] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Threading.Tasks.Task.FinishContinuations () [0x0006f] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Threading.Tasks.Task.FinishStageThree () [0x0003d] in <695d1cc93cca45069c528c15c9fdd749>:0
@nirinchev nirinchev added the T-Bug label Feb 1, 2022
@nirinchev nirinchev self-assigned this Feb 1, 2022
@nirinchev
Copy link
Member Author

I was able to get the following stacktrace when logging in a bunch of users and exiting play mode

/Users/nikolairinchev/work/dotnet/wrappers/realm-core/src/realm/object-store/sync/sync_user.cpp:315: [realm-core-11.9.0] Assertion failed: m_state == SyncUser::State::LoggedIn
0   librealm-wrappers.dylib             0x00000001ae43b06c _ZN5realm4utilL18terminate_internalERNSt3__118basic_stringstreamIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 28
1   librealm-wrappers.dylib             0x00000001ae43b32f _ZN5realm4util9terminateEPKcS2_lOSt16initializer_listINS0_9PrintableEE + 287
2   librealm-wrappers.dylib             0x00000001adbee83b _ZN5realm8SyncUser17update_identitiesENSt3__16vectorINS_16SyncUserIdentityENS1_9allocatorIS3_EEEE + 155
3   librealm-wrappers.dylib             0x00000001adacecc0 _ZZN5realm3app3App11get_profileENSt3__110shared_ptrINS_8SyncUserEEENS2_8functionIFvS5_NS_4util8OptionalINS0_8AppErrorEEEEEEENK4$_13clERKNS0_8ResponseE + 1952
4   librealm-wrappers.dylib             0x00000001adace502 _ZNSt3__1L8__invokeIRZN5realm3app3App11get_profileENS_10shared_ptrINS1_8SyncUserEEENS_8functionIFvS6_NS1_4util8OptionalINS2_8AppErrorEEEEEEE4$_13JNS2_8ResponseEEEEDTclclsr3std3__1E7forwardIT_Efp_Espclsr3std3__1E7forwardIT0_Efp0_EEEOSH_DpOSI_ + 50
5   librealm-wrappers.dylib             0x00000001adace4a2 _ZNSt3__128__invoke_void_return_wrapperIvLb1EE6__callIJRZN5realm3app3App11get_profileENS_10shared_ptrINS3_8SyncUserEEENS_8functionIFvS8_NS3_4util8OptionalINS4_8AppErrorEEEEEEE4$_13NS4_8ResponseEEEEvDpOT_ + 50
6   librealm-wrappers.dylib             0x00000001adace462 _ZNSt3__110__function12__alloc_funcIZN5realm3app3App11get_profileENS_10shared_ptrINS2_8SyncUserEEENS_8functionIFvS7_NS2_4util8OptionalINS3_8AppErrorEEEEEEE4$_13NS_9allocatorISF_EEFvNS3_8ResponseEEEclEOSI_ + 50
7   librealm-wrappers.dylib             0x00000001adacd041 _ZNSt3__110__function6__funcIZN5realm3app3App11get_profileENS_10shared_ptrINS2_8SyncUserEEENS_8functionIFvS7_NS2_4util8OptionalINS3_8AppErrorEEEEEEE4$_13NS_9allocatorISF_EEFvNS3_8ResponseEEEclEOSI_ + 49
8   librealm-wrappers.dylib             0x00000001ad7eaf1a _ZNKSt3__110__function12__value_funcIFvN5realm3app8ResponseEEEclEOS4_ + 74
9   librealm-wrappers.dylib             0x00000001ad7df760 _ZNKSt3__18functionIFvN5realm3app8ResponseEEEclES3_ + 48
10  librealm-wrappers.dylib             0x00000001adae366e _ZZN5realm3app3App24do_authenticated_requestENS0_7RequestENSt3__110shared_ptrINS_8SyncUserEEENS3_8functionIFvNS0_8ResponseEEEEENK4$_21clES8_ + 446
11  librealm-wrappers.dylib             0x00000001adae3463 _ZNSt3__1L8__invokeIRZN5realm3app3App24do_authenticated_requestENS2_7RequestENS_10shared_ptrINS1_8SyncUserEEENS_8functionIFvNS2_8ResponseEEEEE4$_21JS9_EEEDTclclsr3std3__1E7forwardIT_Efp_Espclsr3std3__1E7forwardIT0_Efp0_EEEOSE_DpOSF_ + 67
12  librealm-wrappers.dylib             0x00000001adae33f2 _ZNSt3__128__invoke_void_return_wrapperIvLb1EE6__callIJRZN5realm3app3App24do_authenticated_requestENS4_7RequestENS_10shared_ptrINS3_8SyncUserEEENS_8functionIFvNS4_8ResponseEEEEE4$_21SB_EEEvDpOT_ + 50
13  librealm-wrappers.dylib             0x00000001adae33b2 _ZNSt3__110__function12__alloc_funcIZN5realm3app3App24do_authenticated_requestENS3_7RequestENS_10shared_ptrINS2_8SyncUserEEENS_8functionIFvNS3_8ResponseEEEEE4$_21NS_9allocatorISD_EESB_EclEOSA_ + 50
14  librealm-wrappers.dylib             0x00000001adae2071 _ZNSt3__110__function6__funcIZN5realm3app3App24do_authenticated_requestENS3_7RequestENS_10shared_ptrINS2_8SyncUserEEENS_8functionIFvNS3_8ResponseEEEEE4$_21NS_9allocatorISD_EESB_EclEOSA_ + 49
15  librealm-wrappers.dylib             0x00000001ad7eaf1a _ZNKSt3__110__function12__value_funcIFvN5realm3app8ResponseEEEclEOS4_ + 74
16  librealm-wrappers.dylib             0x00000001ad7df760 _ZNKSt3__18functionIFvN5realm3app8ResponseEEEclES3_ + 48
17  librealm-wrappers.dylib             0x00000001ad7df57c realm_http_transport_respond + 412
18  ???                                 0x000000018ce9efdd 0x0 + 6659108829
19  ???                                 0x000000018c9f3b3b 0x0 + 6654212923
20  ???                                 0x000000018cb33502 0x0 + 6655522050
21  ???                                 0x0000000167d8da23 0x0 + 6037232163
22  ???                                 0x000000018ce8c4f9 0x0 + 6659032313
23  ???                                 0x000000017e380223 0x0 + 6412567075
24  ???                                 0x000000017e37fa3b 0x0 + 6412565051
25  libmonobdwgc-2.0.dylib              0x000000015c75107c mono_jit_runtime_invoke + 1587
26  libmonobdwgc-2.0.dylib              0x000000015c9064d9 do_runtime_invoke + 80
27  libmonobdwgc-2.0.dylib              0x000000015c906416 mono_runtime_invoke + 94
28  Unity                               0x0000000103beb347 _Z23scripting_method_invoke18ScriptingMethodPtr18ScriptingObjectPtrR18ScriptingArgumentsP21ScriptingExceptionPtrb + 71
29  Unity                               0x0000000103be62d6 _ZN19ScriptingInvocation6InvokeEP21ScriptingExceptionPtrb + 166
30  Unity                               0x0000000103d0b306 _ZN9Scripting11UnityEngine32UnitySynchronizationContextProxy12ExecuteTasksEP21ScriptingExceptionPtr + 166
31  Unity                               0x0000000103840d89 _ZZ23InitPlayerLoopCallbacksvEN38UpdateScriptRunDelayedTasksRegistrator7ForwardEv + 57
32  Unity                               0x0000000103831b36 _Z17ExecutePlayerLoopP22NativePlayerLoopSystem + 150
33  Unity                               0x0000000103831af3 _Z17ExecutePlayerLoopP22NativePlayerLoopSystem + 83
34  Unity                               0x0000000103831e65 _Z10PlayerLoopv + 437
35  Unity                               0x0000000104b84d53 _ZN16EditorPlayerLoop7ExecuteEv + 35
36  Unity                               0x0000000104b855d9 _ZN20PlayerLoopController11UpdateSceneEb + 601
37  Unity                               0x0000000104b864d4 _ZN20PlayerLoopController12ExitPlayModeEv + 644
38  Unity                               0x0000000104b7d70f _ZN20PlayerLoopController12SetIsPlayingEb + 735
39  Unity                               0x0000000104b7b800 _ZN11Application9TickTimerEv + 5008
40  Unity                               0x0000000105a68ba9 -[EditorApplication TickTimer] + 361
41  Foundation                          0x00007fff21766e0f __NSFireTimer + 67
42  CoreFoundation                      0x00007fff209aeca9 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
43  CoreFoundation                      0x00007fff209ae79d __CFRunLoopDoTimer + 927
44  CoreFoundation                      0x00007fff209ae2fa __CFRunLoopDoTimers + 307
45  CoreFoundation                      0x00007fff20994ed3 __CFRunLoopRun + 1988
46  CoreFoundation                      0x00007fff2099404c CFRunLoopRunSpecific + 563
47  HIToolbox                           0x00007fff28bdca83 RunCurrentEventLoopInMode + 292
48  HIToolbox                           0x00007fff28bdc6b6 ReceiveNextEventCommon + 284
49  HIToolbox                           0x00007fff28bdc583 _BlockUntilNextEventMatchingListInModeWithFilter + 70
50  AppKit                              0x00007fff2319cd72 _DPSNextEvent + 864
51  AppKit                              0x00007fff2319b545 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1364
52  AppKit                              0x00007fff2318d869 -[NSApplication run] + 586
53  AppKit                              0x00007fff23161a6c NSApplicationMain + 816
54  Unity                               0x0000000105a65d85 _Z10EditorMainiPPKc + 949
55  Unity                               0x0000000105a660a9 main + 9
56  libdyld.dylib                       0x00007fff208b9f3d start + 1!!! IMPORTANT: Please report this at https://github.com/realm/realm-core/issues/new/chooseObtained 0 stack frames.

@nirinchev
Copy link
Member Author

This was fixed with the latest Core update

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

No branches or pull requests

1 participant