Fix Mono netcore TPA preload hook to work with Windows CoreRun.exe. (#32789)
authorJohan Lorensson <lateralusx.github@gmail.com>
Wed, 26 Feb 2020 11:07:04 +0000 (12:07 +0100)
committerGitHub <noreply@github.com>
Wed, 26 Feb 2020 11:07:04 +0000 (12:07 +0100)
Current hook compares TPA list file names using case sensitive compare.
On Windows, the TPA list, when passed from CoreRun.exe makes all file
paths lower case, meaning that our checks fails to find assemblies in
TPA list.

Since CoreRun.exe is used for both CoreCLR and Mono, removing the tolower
on file paths added to the TPA list in CoreRun.exe could be an option,
but that might introduce regressions in CoreCLR, so this fix isolate the
change to Mono's netcore preload hook.

src/mono/mono/mini/monovm.c

index 029ba49..b12781c 100644 (file)
@@ -123,7 +123,7 @@ mono_core_preload_hook (MonoAssemblyLoadContext *alc, MonoAssemblyName *aname, c
        size_t basename_len = strlen (basename);
 
        for (int i = 0; i < a->assembly_count; ++i) {
-               if (basename_len == a->basename_lens [i] && !strncmp (basename, a->basenames [i], a->basename_lens [i])) {
+               if (basename_len == a->basename_lens [i] && !g_strncasecmp (basename, a->basenames [i], a->basename_lens [i])) {
                        MonoAssemblyOpenRequest req;
                        mono_assembly_request_prepare_open (&req, MONO_ASMCTX_DEFAULT, default_alc);
                        req.request.predicate = predicate;