[runtime] Fix a crash on Windows during the cleanup phase caused by using a destroyed...
[mono.git] / mono / metadata / gc.c
index efd062d4405b07439cce8e2a175bcf36ed5f3c5a..03273531193a1f042d36fb185ca99ead3f019565 100644 (file)
@@ -638,12 +638,12 @@ find_first_unset (guint32 bitmap)
        return -1;
 }
 
-static void*
+static MonoGCDescriptor
 make_root_descr_all_refs (int numbits, gboolean pinned)
 {
 #ifdef HAVE_SGEN_GC
        if (pinned)
-               return NULL;
+               return MONO_GC_DESCRIPTOR_NULL;
 #endif
        return mono_gc_make_root_descr_all_refs (numbits);
 }
@@ -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)
 {