[loader] If using strict strong names, recheck loaded assm before returning it.
authorAleksey Kliger <aleksey@xamarin.com>
Mon, 12 Jun 2017 22:11:26 +0000 (18:11 -0400)
committerAleksey Kliger <aleksey@xamarin.com>
Tue, 13 Jun 2017 23:07:52 +0000 (19:07 -0400)
commit5f0dd2998da985eaa3aa15fc46cb924dbf178f96
tree6959cc9b2897d5d52273ade473189f97532c6697
parent87714d8a4516623673d224b6ba4aced1a78391f6
[loader] If using strict strong names, recheck loaded assm before returning it.

Suppose we have two versions of an assembly: AsmA 1.0.0.0 and AsmA 2.0.0.0 that
we want to load into the same domain at the same time (for example we want to
load AsmB and AsmC that statically reference the two versions, respectively, or
maybe we used reflection).  Suppose version 1 got loaded first (and we found it
on our MONO_PATH in "somepathdir/AsmA.dll").  Now we want to load version 2.
The problem is that if version 1 is on MONO_PATH first, we'll find a filename
that matches ("somepathdir/AsmA.dll") and try to open that image.  Then we'll
end up here in mono_assembly_open_predicate() after the mono_image_open_a_lot()
call hits the image cache.  So we get back an image and image->assembly is
version 1.

The old behavior would just return any non-NULL image->assembly.  The new
behavior is to check the predicate and reject opening the propose file if the
predicate doesn't match.  (If we're not using the strict loader, or if there's
no predicate set, return the existing image->assembly as before).
mono/metadata/assembly.c