summaryrefslogtreecommitdiff
path: root/mono/metadata/appdomain.c
diff options
context:
space:
mode:
Diffstat (limited to 'mono/metadata/appdomain.c')
-rw-r--r--mono/metadata/appdomain.c69
1 files changed, 30 insertions, 39 deletions
diff --git a/mono/metadata/appdomain.c b/mono/metadata/appdomain.c
index 20ccd0c489..068a1df275 100644
--- a/mono/metadata/appdomain.c
+++ b/mono/metadata/appdomain.c
@@ -62,6 +62,7 @@
#include <mono/utils/mono-error-internals.h>
#include <mono/utils/atomic.h>
#include <mono/utils/mono-memory-model.h>
+#include <mono/utils/mono-threads.h>
#ifdef HOST_WIN32
#include <direct.h>
#endif
@@ -77,7 +78,7 @@
* Changes which are already detected at runtime, like the addition
* of icalls, do not require an increment.
*/
-#define MONO_CORLIB_VERSION 110
+#define MONO_CORLIB_VERSION 111
typedef struct
{
@@ -476,7 +477,6 @@ mono_domain_create_appdomain_internal (char *friendly_name, MonoAppDomainSetup *
shadow_location = get_shadow_assembly_location_base (data, &error);
if (!mono_error_ok (&error))
mono_error_raise_exception (&error);
- mono_debugger_event_create_appdomain (data, shadow_location);
g_free (shadow_location);
#endif
@@ -1609,6 +1609,7 @@ mono_make_shadow_copy (const char *filename)
gchar *sibling_source, *sibling_target;
gint sibling_source_len, sibling_target_len;
guint16 *orig, *dest;
+ guint32 attrs;
char *shadow;
gboolean copy_result;
MonoException *exc;
@@ -1661,6 +1662,16 @@ mono_make_shadow_copy (const char *filename)
orig = g_utf8_to_utf16 (filename, strlen (filename), NULL, NULL, NULL);
dest = g_utf8_to_utf16 (shadow, strlen (shadow), NULL, NULL, NULL);
DeleteFile (dest);
+
+ /* Fix for bug #17066 - make sure we can read the file. if not then don't error but rather
+ * let the assembly fail to load. This ensures you can do Type.GetType("NS.T, NonExistantAssembly)
+ * and not have it runtime error" */
+ attrs = GetFileAttributes (orig);
+ if (attrs == INVALID_FILE_ATTRIBUTES) {
+ g_free (shadow);
+ return (char *)filename;
+ }
+
copy_result = CopyFile (orig, dest, FALSE);
/* Fix for bug #556884 - make sure the files have the correct mode so that they can be
@@ -1945,7 +1956,9 @@ ves_icall_System_AppDomain_LoadAssembly (MonoAppDomain *ad, MonoString *assRef,
if (!parsed) {
/* This is a parse error... */
- return NULL;
+ if (!refOnly)
+ refass = mono_try_assembly_resolve (domain, assRef, refOnly);
+ return refass;
}
ass = mono_assembly_load_full_nosearch (&aname, NULL, &status, refOnly);
@@ -2176,7 +2189,7 @@ zero_static_data (MonoVTable *vtable)
void *data;
if (klass->has_static_refs && (data = mono_vtable_get_static_field_data (vtable)))
- mono_gc_bzero (data, mono_class_data_size (klass));
+ mono_gc_bzero_aligned (data, mono_class_data_size (klass));
}
typedef struct unload_data {
@@ -2201,23 +2214,6 @@ unload_data_unref (unload_data *data)
}
static void
-deregister_reflection_info_roots_nspace_table (gpointer key, gpointer value, gpointer image)
-{
- guint32 index = GPOINTER_TO_UINT (value);
- MonoClass *class = mono_class_get (image, MONO_TOKEN_TYPE_DEF | index);
-
- g_assert (class);
-
- mono_class_free_ref_info (class);
-}
-
-static void
-deregister_reflection_info_roots_name_space (gpointer key, gpointer value, gpointer user_data)
-{
- g_hash_table_foreach (value, deregister_reflection_info_roots_nspace_table, user_data);
-}
-
-static void
deregister_reflection_info_roots_from_list (MonoImage *image)
{
GSList *list = image->reflection_info_unregister_classes;
@@ -2230,7 +2226,6 @@ deregister_reflection_info_roots_from_list (MonoImage *image)
list = list->next;
}
- g_slist_free (image->reflection_info_unregister_classes);
image->reflection_info_unregister_classes = NULL;
}
@@ -2239,29 +2234,28 @@ deregister_reflection_info_roots (MonoDomain *domain)
{
GSList *list;
- mono_loader_lock ();
mono_domain_assemblies_lock (domain);
for (list = domain->domain_assemblies; list; list = list->next) {
MonoAssembly *assembly = list->data;
MonoImage *image = assembly->image;
int i;
- /*No need to take the image lock here since dynamic images are appdomain bound and at this point the mutator is gone.*/
- if (image->dynamic && image->name_cache)
- g_hash_table_foreach (image->name_cache, deregister_reflection_info_roots_name_space, image);
- deregister_reflection_info_roots_from_list (image);
+
+ /*
+ * No need to take the image lock here since dynamic images are appdomain bound and
+ * at this point the mutator is gone. Taking the image lock here would mean
+ * promoting it from a simple lock to a complex lock, which we better avoid if
+ * possible.
+ */
+ if (image->dynamic)
+ deregister_reflection_info_roots_from_list (image);
+
for (i = 0; i < image->module_count; ++i) {
MonoImage *module = image->modules [i];
- if (module) {
- if (module->dynamic && module->name_cache) {
- g_hash_table_foreach (module->name_cache,
- deregister_reflection_info_roots_name_space, module);
- }
+ if (module && module->dynamic)
deregister_reflection_info_roots_from_list (module);
- }
}
}
mono_domain_assemblies_unlock (domain);
- mono_loader_unlock ();
}
static guint32 WINAPI
@@ -2390,7 +2384,6 @@ void
mono_domain_try_unload (MonoDomain *domain, MonoObject **exc)
{
HANDLE thread_handle;
- gsize tid;
MonoAppDomainState prev_state;
MonoMethod *method;
unload_data *thread_data;
@@ -2417,8 +2410,6 @@ mono_domain_try_unload (MonoDomain *domain, MonoObject **exc)
}
}
- mono_debugger_event_unload_appdomain (domain);
-
mono_domain_set (domain, FALSE);
/* Notify OnDomainUnload listeners */
method = mono_class_get_method_from_name (domain->domain->mbr.obj.vtable->klass, "DoDomainUnload", -1);
@@ -2451,9 +2442,9 @@ mono_domain_try_unload (MonoDomain *domain, MonoObject **exc)
* http://bugzilla.ximian.com/show_bug.cgi?id=27663
*/
#if 0
- thread_handle = mono_create_thread (NULL, 0, unload_thread_main, &thread_data, 0, &tid);
+ thread_handle = mono_threads_create_thread (unload_thread_main, thread_data, 0, 0, NULL);
#else
- thread_handle = mono_create_thread (NULL, 0, (LPTHREAD_START_ROUTINE)unload_thread_main, thread_data, CREATE_SUSPENDED, &tid);
+ thread_handle = mono_threads_create_thread ((LPTHREAD_START_ROUTINE)unload_thread_main, thread_data, 0, CREATE_SUSPENDED, NULL);
if (thread_handle == NULL) {
return;
}