Skip to content

Commit afa21ce

Browse files
Josh Petersonjoncham
authored andcommitted
Don't shutdown in mono_runtime_try_shutdown
The Mono implementation of mono_runtime_try_shutdown does not actually shut down the VM. Instead, it sets the flags to indicate the VM is shutting down. The VM should actually shutdown in mono_runtime_quit. In some cases, we see this code path taken when processing the CMD_VM_EXIT command. This seems unlikely, but can happen when the code above cannot find a suspended managed thread. If mono_runtime_try_shutdown actually waits for managed threads to complete, it will hang, as the main thread won't be suspended because resume_vm is called just above mono_runtime_try_shutdown. So for IL2CPP mono_runtime_try_shutdown doesn't do anything, but mono_runtime_quit will actually shutdown the VM.
1 parent 7c74147 commit afa21ce

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

mono/mini/il2cpp-stubs.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,12 @@ MonoDomain* il2cpp_mono_get_root_domain (void)
503503

504504
void il2cpp_mono_runtime_quit (void)
505505
{
506-
IL2CPP_ASSERT(0 && "This method is not yet implemented");
506+
#if UNITY_TINY
507+
IL2CPP_ASSERT(0 && "Not implemented yet for tiny");
508+
return 0;
509+
#else
510+
il2cpp::vm::Runtime::Shutdown();
511+
#endif
507512
}
508513

509514
gboolean il2cpp_mono_runtime_is_shutting_down (void)
@@ -1265,13 +1270,7 @@ MonoImage* il2cpp_mono_assembly_get_image(MonoAssembly* assembly)
12651270

12661271
gboolean il2cpp_mono_runtime_try_shutdown()
12671272
{
1268-
#if UNITY_TINY
1269-
IL2CPP_ASSERT(0 && "Not implemented yet for tiny");
1270-
return 0;
1271-
#else
1272-
il2cpp::vm::Runtime::Shutdown();
1273-
return TRUE;
1274-
#endif
1273+
return TRUE;
12751274
}
12761275

12771276
gboolean il2cpp_mono_verifier_is_method_valid_generic_instantiation(MonoMethod* method)

0 commit comments

Comments
 (0)