summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Kurinnoi/AI Compiler Lab /SRR/Staff Engineer/Samsung Electronics <m.kurinnoi@samsung.com>2020-06-26 01:30:09 +0300
committerHyungju Lee <leee.lee@samsung.com>2020-10-07 07:23:06 +0900
commitcee50c8cfe92e940124e7c9bdb421e546842b483 (patch)
tree3d831ce90f534b1c85caee67ee758769e2a4985a
parentc9d9ed464fe145cbc17b3f752061994319a07c2b (diff)
downloadcoreclr-tizen_5.0_base.tar.gz
coreclr-tizen_5.0_base.tar.bz2
coreclr-tizen_5.0_base.zip
Fix TPA map hash calculation. (#288)submit/tizen_5.0_base/20210129.022026tizen_5.0_base
* Fix TPA map hash calculation. The point of issue is "the Turkish-I Problem". After locale changed, towupper() provide another result for "i" and different hash are calculated in case if file name have "i" letter. * Regression test for #37910
-rw-r--r--src/binder/inc/applicationcontext.hpp8
-rw-r--r--src/coreclr/tests/src/Loader/binding/assemblies/assemblybugs/37910/Ii.cs39
-rw-r--r--src/coreclr/tests/src/Loader/binding/assemblies/assemblybugs/37910/Ii.csproj12
3 files changed, 57 insertions, 2 deletions
diff --git a/src/binder/inc/applicationcontext.hpp b/src/binder/inc/applicationcontext.hpp
index 9c8926207c..2f95fe68dd 100644
--- a/src/binder/inc/applicationcontext.hpp
+++ b/src/binder/inc/applicationcontext.hpp
@@ -71,8 +71,12 @@ namespace BINDER_SPACE
key = e.m_wszSimpleName;
return key;
}
- static count_t Hash(const key_t &str) { return HashiString(str); }
- static BOOL Equals(const key_t &lhs, const key_t &rhs) { LIMITED_METHOD_CONTRACT; return (_wcsicmp(lhs, rhs) == 0); }
+ static count_t Hash(const key_t &str)
+ {
+ SString ssKey(SString::Literal, str);
+ return ssKey.HashCaseInsensitive();
+ }
+ static BOOL Equals(const key_t &lhs, const key_t &rhs) { LIMITED_METHOD_CONTRACT; return (SString::_wcsicmp(lhs, rhs) == 0); }
void OnDestructPerEntryCleanupAction(const SimpleNameToFileNameMapEntry & e)
{
diff --git a/src/coreclr/tests/src/Loader/binding/assemblies/assemblybugs/37910/Ii.cs b/src/coreclr/tests/src/Loader/binding/assemblies/assemblybugs/37910/Ii.cs
new file mode 100644
index 0000000000..65f0ea68c0
--- /dev/null
+++ b/src/coreclr/tests/src/Loader/binding/assemblies/assemblybugs/37910/Ii.cs
@@ -0,0 +1,39 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+public class Program
+{
+ [DllImport("libc", EntryPoint = "setlocale")]
+ public static extern IntPtr setlocale(int category, [MarshalAs(UnmanagedType.LPStr)] string locale);
+
+ public static int Main()
+ {
+ Assembly a1 = Assembly.GetExecutingAssembly();
+
+ // In case of Turkish locale:
+ // towupper 'i' -> \x0130 (instead of 'I')
+ // towlower 'I' -> \x0131 (instead of 'i')
+ const string TRLocale = "tr_TR.UTF-8";
+ IntPtr res = setlocale(6 /*LC_ALL*/, TRLocale);
+ if (TRLocale != Marshal.PtrToStringAnsi(res))
+ {
+ Console.WriteLine("Failed! " + TRLocale + " locale was not found in system!");
+ return -1;
+ }
+
+ Assembly a2 = Assembly.Load("Ii");
+
+ if (a1 != a2)
+ {
+ Console.WriteLine("Failed!");
+ return -2;
+ }
+
+ Console.WriteLine("Passed!");
+ return 100;
+ }
+}
diff --git a/src/coreclr/tests/src/Loader/binding/assemblies/assemblybugs/37910/Ii.csproj b/src/coreclr/tests/src/Loader/binding/assemblies/assemblybugs/37910/Ii.csproj
new file mode 100644
index 0000000000..d1d1441426
--- /dev/null
+++ b/src/coreclr/tests/src/Loader/binding/assemblies/assemblybugs/37910/Ii.csproj
@@ -0,0 +1,12 @@
+<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <CLRTestPriority>1</CLRTestPriority>
+ <!-- Test unsupported outside of linux -->
+ <CLRTestTargetUnsupported Condition="'$(TargetOS)' != 'Linux'">true</CLRTestTargetUnsupported>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="Ii.cs" />
+ </ItemGroup>
+</Project>