[runtime] Fix a crash on Windows during the cleanup phase caused by using a destroyed...
authorVladimir Kargov <vkargov@users.noreply.github.com>
Mon, 29 Jun 2015 21:15:11 +0000 (00:15 +0300)
committerVladimir Kargov <vkargov@users.noreply.github.com>
Mon, 29 Jun 2015 21:15:11 +0000 (00:15 +0300)
mono/metadata/gc-internal.h
mono/metadata/gc.c
mono/mini/mini-runtime.c

index 1511280bd8874220d41fe077b7f5f2fc7bd72a3d..d55e56d5d0dd653e5ba9c528c0b9a68c1e4d4fb9 100644 (file)
@@ -84,6 +84,7 @@ MonoBoolean ves_icall_Mono_Runtime_SetGCAllowSynchronousMajor (MonoBoolean flag)
 extern void mono_gc_init (void);
 extern void mono_gc_base_init (void);
 extern void mono_gc_cleanup (void);
+extern void mono_gc_mutex_cleanup (void);
 extern void mono_gc_base_cleanup (void);
 
 /*
index b69b450bf14ad040afa4b44365e0070c1d281953..03273531193a1f042d36fb185ca99ead3f019565 100644 (file)
@@ -1275,12 +1275,22 @@ mono_gc_cleanup (void)
 
        mono_reference_queue_cleanup ();
 
-       mono_mutex_destroy (&handle_section);
        mono_mutex_destroy (&allocator_section);
        mono_mutex_destroy (&finalizer_mutex);
        mono_mutex_destroy (&reference_queue_mutex);
 }
 
+/**
+ * mono_gc_mutex_cleanup:
+ *
+ * Destroy the mutexes that may still be used after the main cleanup routine.
+ */
+void
+mono_gc_mutex_cleanup (void)
+{
+       mono_mutex_destroy (&handle_section);
+}
+
 gboolean
 mono_gc_is_finalizer_internal_thread (MonoInternalThread *thread)
 {
index a306f3fdf12b97d876e70ababfe5b80020dc51e9..b597688610482ec362dd8d1ea444b0caed4c75ab 100644 (file)
@@ -3452,6 +3452,7 @@ mini_cleanup (MonoDomain *domain)
 
 #ifndef MONO_CROSS_COMPILE
        mono_domain_free (domain, TRUE);
+       mono_gc_mutex_cleanup ();
 #endif
 
 #ifdef ENABLE_LLVM