Merge pull request #868 from mariokmk/master
[mono.git] / mono / metadata / image.c
index 9c2dff1dd05e3eae386bacf9eb2460ce8464dd93..dcb5c399a62edab973fd29eba6650b7071ab56ba 100644 (file)
@@ -1650,6 +1650,7 @@ mono_image_close_except_pools (MonoImage *image)
        free_hash (image->native_wrapper_aot_cache);
        free_hash (image->pinvoke_scopes);
        free_hash (image->pinvoke_scope_filenames);
+       free_hash (image->gsharedvt_types);
 
        /* The ownership of signatures is not well defined */
        g_hash_table_destroy (image->memberref_signatures);
@@ -1662,7 +1663,11 @@ mono_image_close_except_pools (MonoImage *image)
        if (image->property_hash)
                mono_property_hash_destroy (image->property_hash);
 
-       g_slist_free (image->reflection_info_unregister_classes);
+       /*
+       reflection_info_unregister_classes is only required by dynamic images, which will not be properly
+       cleared during shutdown as we don't perform regular appdomain unload for the root one.
+       */
+       g_assert (!image->reflection_info_unregister_classes || mono_runtime_is_shutting_down ());
        image->reflection_info_unregister_classes = NULL;
 
        if (image->interface_bitset) {
@@ -1707,12 +1712,6 @@ void
 mono_image_close_finish (MonoImage *image)
 {
        int i;
-       GSList *l;
-
-       for (l = image->reflection_info_unregister_classes; l; l = l->next)
-               g_free (l->data);
-       g_slist_free (image->reflection_info_unregister_classes);
-       image->reflection_info_unregister_classes = NULL;
 
        if (image->references && !image->dynamic) {
                for (i = 0; i < image->nreferences; i++) {
@@ -2360,3 +2359,13 @@ mono_image_property_remove (MonoImage *image, gpointer subject)
        mono_property_hash_remove_object (image->property_hash, subject);
        mono_image_unlock (image);
 }
+
+void
+mono_image_append_class_to_reflection_info_set (MonoClass *class)
+{
+       MonoImage *image = class->image;
+       g_assert (image->dynamic);
+       mono_image_lock (image);
+       image->reflection_info_unregister_classes = g_slist_prepend_mempool (image->mempool, image->reflection_info_unregister_classes, class);
+       mono_image_unlock (image);
+}