[loader] Set image assembly before reference attribute assembly check.
authorAleksey Kliger <aleksey@xamarin.com>
Fri, 21 Oct 2016 13:29:28 +0000 (09:29 -0400)
committerAleksey Kliger <aleksey@xamarin.com>
Fri, 21 Oct 2016 14:30:35 +0000 (10:30 -0400)
In mono_assembly_load_from_full, the call to
mono_assembly_has_reference_assembly_attribute has to come after
image->assembly is set.  This is because image->assembly->base_dir is
used for probing for referenced assemblies, and the reference assembly
attribute check will probe for assemblies referenced by the custom
attributes on the assembly in image being loaded.

mono/metadata/assembly.c

index ff098ae934f8f7cf3279e0bb0d1ed9a5763302fb..51a27929632acf27c1cb9060a7d2089911445d61 100644 (file)
@@ -1847,7 +1847,7 @@ mono_assembly_has_reference_assembly_attribute (MonoAssembly *assembly, MonoErro
  * corlib, however, so we need a more robust version that doesn't care
  * about missing attributes.
  */
-#if 0
+#if 1
        MonoCustomAttrInfo *attrs = mono_custom_attrs_from_assembly_checked (assembly, TRUE, error);
        return_val_if_nok (error, FALSE);
        if (!attrs)
@@ -1999,6 +1999,8 @@ mono_assembly_load_from_full (MonoImage *image, const char*fname,
 
        mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_ASSEMBLY, "Prepared to set up assembly '%s' (%s)", ass->aname.name, image->name);
 
+       image->assembly = ass;
+
        /* We need to check for ReferenceAssmeblyAttribute before we
         * mark the assembly as loaded and before we fire the load
         * hook. Otherwise mono_domain_fire_assembly_load () in
@@ -2027,8 +2029,6 @@ mono_assembly_load_from_full (MonoImage *image, const char*fname,
                mono_error_cleanup (&refasm_error);
        }
 
-       image->assembly = ass;
-
        loaded_assemblies = g_list_prepend (loaded_assemblies, ass);
        mono_assemblies_unlock ();