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 Crash #3344

Closed
avolkangursel opened this issue Jun 7, 2023 · 1 comment · Fixed by #3386
Closed

Unity Editor Crash #3344

avolkangursel opened this issue Jun 7, 2023 · 1 comment · Fixed by #3386

Comments

@avolkangursel
Copy link

What happened?

I occasionally encounter an error in the Unity editor. It crashes and closes the editor.

Repro steps

I'm not exactly sure how to reproduce it consistently. It might be related to AssemblyReload when code changes during runtime. I'm not sure.

Version

11.0.0

What Atlas Services are you using?

Atlas Device Sync

What type of application is this?

Unity

Client OS and version

MacOS 13.0.1

Code snippets

No response

Stacktrace of the exception/crash you're getting

/Users/runner/work/realm-dotnet/realm-dotnet/wrappers/realm-core/src/realm/object-store/impl/realm_coordinator.cpp:374: [realm-core-13.10.1] Invalid Realm passed to bind_to_context()
0   librealm-wrappers.dylib             0x00000002cdb14f3c _ZN5realm4util19terminate_with_infoEPKcS2_lS2_OSt16initializer_listINS0_9PrintableEE + 400
1   librealm-wrappers.dylib             0x00000002cdb14dac _ZN5realm4util19terminate_with_infoEPKcS2_lS2_OSt16initializer_listINS0_9PrintableEE + 0
2   librealm-wrappers.dylib             0x00000002cd817e4c _ZN5realm5Realm16get_shared_realmENS_19ThreadSafeReferenceENSt3__110shared_ptrINS_4util9SchedulerEEE + 436
3   librealm-wrappers.dylib             0x00000002cd73c998 shared_realm_resolve_realm_reference + 64
4   ???                                 0x000000046166e884 0x0 + 18814003332
5   ???                                 0x000000046166e618 0x0 + 18814002712
6   ???                                 0x000000045ed5452c 0x0 + 18770904364
7   ???                                 0x000000045d3ee558 0x0 + 18744272216
8   ???                                 0x000000045cfaa304 0x0 + 18739798788
9   ???                                 0x000000045cfa9ebc 0x0 + 18739797692
10  ???                                 0x000000045d3ecd90 0x0 + 18744266128
11  ???                                 0x000000045ed39c70 0x0 + 18770795632
12  ???                                 0x000000045ed39aec 0x0 + 18770795244
13  ???                                 0x000000045e4e7e68 0x0 + 18762071656
14  ???                                 0x000000045e4e7bc4 0x0 + 18762070980
15  ???                                 0x000000045ca1151c 0x0 + 18733929756
16  libmonobdwgc-2.0.dylib              0x00000002e08d5818 mono_jit_runtime_invoke + 1924
17  libmonobdwgc-2.0.dylib              0x00000002e0a5b624 do_runtime_invoke + 104
18  libmonobdwgc-2.0.dylib              0x00000002e0a5b544 mono_runtime_invoke + 100
19  Unity                               0x0000000102df9f1c _Z23scripting_method_invoke18ScriptingMethodPtr18ScriptingObjectPtrR18ScriptingArgumentsP21ScriptingExceptionPtrb + 88
20  Unity                               0x0000000102dd7de8 _ZN19ScriptingInvocation6InvokeEP21ScriptingExceptionPtrb + 164
21  Unity                               0x0000000102f0e13c _ZN9Scripting11UnityEngine32UnitySynchronizationContextProxy12ExecuteTasksEP21ScriptingExceptionPtr + 156
22  Unity                               0x0000000102a7f7b4 _ZZ23InitPlayerLoopCallbacksvEN38UpdateScriptRunDelayedTasksRegistrator7ForwardEv + 56
23  Unity                               0x0000000102a70eb0 _Z17ExecutePlayerLoopP22NativePlayerLoopSystem + 196
24  Unity                               0x0000000102a70e78 _Z17ExecutePlayerLoopP22NativePlayerLoopSystem + 140
25  Unity                               0x0000000102a712b8 _Z10PlayerLoopv + 444
26  Unity                               0x0000000103ca6f6c _ZN16EditorPlayerLoop7ExecuteEv + 40
27  Unity                               0x0000000103ca7748 _ZN20PlayerLoopController11UpdateSceneEb + 512
28  Unity                               0x0000000103ca84e4 _ZN20PlayerLoopController12ExitPlayModeEv + 548
29  Unity                               0x0000000103c9f944 _ZN20PlayerLoopController12SetIsPlayingEb + 572
30  Unity                               0x0000000103c9dbd4 _ZN11Application9TickTimerEv + 4432
31  Unity                               0x0000000104a6dd04 -[EditorApplication TickTimer] + 416
32  Foundation                          0x000000019e1c467c __NSFireTimer + 104
33  CoreFoundation                      0x000000019d29f578 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 32
34  CoreFoundation                      0x000000019d29f220 __CFRunLoopDoTimer + 940
35  CoreFoundation                      0x000000019d29ed78 __CFRunLoopDoTimers + 356
36  CoreFoundation                      0x000000019d284760 __CFRunLoopRun + 1896
37  CoreFoundation                      0x000000019d2838a4 CFRunLoopRunSpecific + 612
38  HIToolbox                           0x00000001a68f73bc RunCurrentEventLoopInMode + 292
39  HIToolbox                           0x00000001a68f704c ReceiveNextEventCommon + 236
40  HIToolbox                           0x00000001a68f6f48 _BlockUntilNextEventMatchingListInModeWithFilter + 72
41  AppKit                              0x00000001a04dc630 _DPSNextEvent + 632
42  AppKit                              0x00000001a04db7c0 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 728
43  AppKit                              0x00000001a04cfbf0 -[NSApplication run] + 464
44  AppKit                              0x00000001a04a7058 NSApplicationMain + 880
45  Unity                               0x0000000104a6aedc _Z10EditorMainiPPKc + 896
46  Unity                               0x0000000104a6b214 main + 12
47  dyld                                0x000000019ce7be50 start + 2544
!!! IMPORTANT: Please report this at https://github.com/realm/realm-core/issues/new/chooseObtained 52 stack frames.
#0  0x0000019d16f224 in __pthread_kill
#1  0x633680019d0df2c8 in abort
#2  0x107a0002cdb14d98 in realm::util::terminate(char const*, char const*, long, std::initializer_list<realm::util::Printable>&&)
#3  0x000002cdb1514c in realm::util::terminate_internal(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&)
#4  0x000002cdb14f3c in realm::util::terminate_with_info(char const*, char const*, long, char const*, std::initializer_list<realm::util::Printable>&&)
#5  0x000002cdb14dac in realm::util::terminate_with_info(char const*, char const*, long, char const*, std::initializer_list<realm::util::Printable>&&)
#6  0x000002cd817e4c in realm::Realm::get_shared_realm(realm::ThreadSafeReference, std::__1::shared_ptr<realm::util::Scheduler>)
#7  0x000002cd73c998 in shared_realm_resolve_realm_reference
#8  0x0000046166e884 in  (wrapper managed-to-native) Realms.SharedRealmHandle/NativeMethods:resolve_realm_reference (Realms.ThreadSafeReferenceHandle,Realms.NativeException&) [{0x44d1f3a10} + 0x16c]  (0x46166e718 0x46166e9ac) [0x169bc2a80 - Unity Child Domain]
#9  0x0000046166e618 in  Realms.SharedRealmHandle:ResolveFromReference (Realms.ThreadSafeReferenceHandle) [{0x3af1fda30} + 0x70]  (0x46166e5a8 0x46166e694) [0x169bc2a80 - Unity Child Domain]
#10 0x0000045ed5452c in  Realms.Sync.SyncConfigurationBase/<CreateHandleAsync>d__25:MoveNext () [{0x3af1fd8b8} + 0x854]  (0x45ed53cd8 0x45ed549a8) [0x169bc2a80 - Unity Child Domain]
#11 0x0000045d3ee558 in  System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner:InvokeMoveNext (object) [{0x31019c1b0} + 0xe8]  (0x45d3ee470 0x45d3ee58c) [0x169bc2a80 - Unity Child Domain]
#12 0x0000045cfaa304 in  System.Threading.ExecutionContext:RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [{0x2e4b98048} + 0x3d4]  (0x45cfa9f30 0x45cfaa390) [0x169bc2a80 - Unity Child Domain]
#13 0x0000045cfa9ebc in  System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [{0x2e4b97bd0} + 0x6c]  (0x45cfa9e50 0x45cfa9ee0) [0x169bc2a80 - Unity Child Domain]
#14 0x0000045d3ecd90 in  System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner:Run () [{0x310869ee0} + 0x178]  (0x45d3ecc18 0x45d3ece6c) [0x169bc2a80 - Unity Child Domain]
#15 0x0000045ed39c70 in  System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation/<>c:<.cctor>b__7_0 (object) [{0x30e1def10} + 0x90]  (0x45ed39be0 0x45ed39ca8) [0x169bc2a80 - Unity Child Domain]
#16 0x0000045ed39aec in  UnityEngine.UnitySynchronizationContext/WorkRequest:Invoke () [{0x4471181c0} + 0x8c] [/Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnitySynchronizationContext.cs :: 153u] (0x45ed39a60 0x45ed39bac) [0x169bc2a80 - Unity Child Domain]
#17 0x0000045e4e7e68 in  UnityEngine.UnitySynchronizationContext:Exec () [{0x30a7f3400} + 0x208] [/Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnitySynchronizationContext.cs :: 83u] (0x45e4e7c60 0x45e4e7f08) [0x169bc2a80 - Unity Child Domain]
#18 0x0000045e4e7bc4 in  UnityEngine.UnitySynchronizationContext:ExecuteTasks () [{0x30a7f3478} + 0xe4] [/Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnitySynchronizationContext.cs :: 107u] (0x45e4e7ae0 0x45e4e7c00) [0x169bc2a80 - Unity Child Domain]
#19 0x0000045ca1151c in  (wrapper runtime-invoke) object:runtime_invoke_void (object,intptr,intptr,intptr) [{0x30a36b3f0} + 0x11c]  (0x45ca11400 0x45ca116a0) [0x169bc2a80 - Unity Child Domain]
#20 0x000002e08d5818 in mono_jit_runtime_invoke
#21 0x000002e0a5b624 in do_runtime_invoke
#22 0x000002e0a5b544 in mono_runtime_invoke
#23 0x00000102df9f1c in scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool)
#24 0x00000102dd7de8 in ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)
#25 0x00000102f0e13c in Scripting::UnityEngine::UnitySynchronizationContextProxy::ExecuteTasks(ScriptingExceptionPtr*)
#26 0x00000102a7f7b4 in InitPlayerLoopCallbacks()::UpdateScriptRunDelayedTasksRegistrator::Forward()
#27 0x00000102a70eb0 in ExecutePlayerLoop(NativePlayerLoopSystem*)
#28 0x00000102a70e78 in ExecutePlayerLoop(NativePlayerLoopSystem*)
#29 0x00000102a712b8 in PlayerLoop()
#30 0x00000103ca6f6c in EditorPlayerLoop::Execute()
#31 0x00000103ca7748 in PlayerLoopController::UpdateScene(bool)
#32 0x00000103ca84e4 in PlayerLoopController::ExitPlayMode()
#33 0x00000103c9f944 in PlayerLoopController::SetIsPlaying(bool)
#34 0x00000103c9dbd4 in Application::TickTimer()
#35 0x00000104a6dd04 in -[EditorApplication TickTimer]
#36 0x0000019e1c467c in __NSFireTimer
#37 0xa12280019d29f578 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
#38 0xb14a00019d29f220 in __CFRunLoopDoTimer
#39 0xdb0880019d29ed78 in __CFRunLoopDoTimers
#40 0xaa7200019d284760 in __CFRunLoopRun
#41 0xe54200019d2838a4 in CFRunLoopRunSpecific
#42 0xd3760001a68f73bc in RunCurrentEventLoopInMode
#43 0x3e4d0001a68f704c in ReceiveNextEventCommon
#44 0x5c0a8001a68f6f48 in _BlockUntilNextEventMatchingListInModeWithFilter
#45 0x42590001a04dc630 in _DPSNextEvent
#46 0xf2740001a04db7c0 in -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
#47 0xbe780001a04cfbf0 in -[NSApplication run]
#48 0xa2058001a04a7058 in NSApplicationMain
#49 0x853c000104a6aedc in EditorMain(int, char const**)
#50 0x00000104a6b214 in main
#51 0x0000019ce7be50 in start
Launching bug reporter
Attribute Qt::AA_EnableHighDpiScaling must be set before QCoreApplication is created.
QObject: Cannot create children for a parent that is in a different thread.
(Parent is QObject(0x7fb0cb2e2210), parent's thread is QThread(0x7fb0cb004a60), current thread is Thread(0x7fb0aa75e9b0)

Relevant log output

No response

@nirinchev
Copy link
Member

This appears to be a race condition when using GetInstanceAsync and reloading the domain. Don't have the full picture yet, but it appears to be caused by the async open callback firing after we have cleared the native caches due to the domain unloading. Right now I don't see an easy way to avoid it, but will try and come up with a repro case and hopefully a workaround.

@nirinchev nirinchev self-assigned this Jun 9, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 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