[runtime] Respect runtime_version in mono_init_internal (mono/mono#17085)
authorAleksey Kliger (λgeek) <alklig@microsoft.com>
Thu, 26 Sep 2019 21:30:37 +0000 (17:30 -0400)
committerGitHub <noreply@github.com>
Thu, 26 Sep 2019 21:30:37 +0000 (17:30 -0400)
commit2f8731443bb05f38011959646325ffc505c5255c
tree07473341e9510e43c50e330bfc32a8095b1b9bf3
parentfdcec9fd931b974df08e055f5684d61268c11ef5
[runtime] Respect runtime_version in mono_init_internal (mono/mono#17085)

In mono/mono@6d2c77fb3373971b4c615a70fe43f3622e3c91d8 we changed the representation of
the runtimes that we will probe from a NULL-terminated array to a linked list.
Unfortunately we made a typo, and in the case where the caller of
mono_init_internal provided a runtime_version, we still picked
DEFAULT_RUNTIME_VERSION instead of the given runtime_version.

This is an issue for embedders like XA that use the "mobile" runtime - all
their assemblies are compiled with the "mobile" version number (2.0.5.0) but
Mono running with the default runtime configuration will remap to 4.0.0.0.  As
a result, when there are references to 2.0.5.0 assemblies, the load requests
will be remapped to 4.0.0.0 which will never see the already loaded 2.0.5.0
assemblies, and we will fall back on the embedder's preload hook or filesystem
probing every single time.  This is a performance fail.

Commit migrated from https://github.com/mono/mono/commit/1dc63ced73eefe7c19cbe51efd6b1b85026e8b0a
src/mono/mono/metadata/domain.c