Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileNotFoundException w/ ku-TR.UTF-8 #37778

Closed
HJLeee opened this issue Jun 11, 2020 · 5 comments
Closed

FileNotFoundException w/ ku-TR.UTF-8 #37778

HJLeee opened this issue Jun 11, 2020 · 5 comments

Comments

@HJLeee
Copy link
Contributor

HJLeee commented Jun 11, 2020

Description

Locale change to/from ku-TR.UTF-8 creates FileNotFoundException for TPA when .NET application has ability to detect and update the locale according to the system locale changes.

I/DOTNET_LAUNCHER(23387): Unhandled exception.
I/DOTNET_LAUNCHER(23387): System.IO.FileNotFoundException: Could not load file or assembly 'System.Collections, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
I/DOTNET_LAUNCHER(23387):
I/DOTNET_LAUNCHER(23387): File name: 'System.Collections, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
I/DOTNET_LAUNCHER(23387):    at ElmSharp.Window..ctor(Window parent, String name, WindowType type)
I/DOTNET_LAUNCHER(23387):    at Xamarin.Forms.Platform.Tizen.FormsApplication.OnPreCreate()
I/DOTNET_LAUNCHER(23387):    at Tizen.Applications.CoreBackend.UICoreBackend.OnCreateNative(IntPtr data)
I/DOTNET_LAUNCHER(23387):    at Tizen.Applications.CoreBackend.UICoreBackend.Run(String[] args)
I/DOTNET_LAUNCHER(23387):    at Tizen.Applications.CoreApplication.Run(String[] args)
I/DOTNET_LAUNCHER(23387):    at Tizen.Applications.CoreUIApplication.Run(String[] args)
I/DOTNET_LAUNCHER(23387):    at Alarm.Program.Main(String[] args)
I/DOTNET_LAUNCHER(23387):
I/DOTNET_LAUNCHER(23387):
I/DOTNET_LAUNCHER(23387): onSigabrt called

It's because in some languages like Turkish, i is not converted into I for toupper() call.
https://blog.codinghorror.com/whats-wrong-with-turkey/

Checking for all possible locale in a Tizen device, 16 cases are found.

Culture: az lower: abcdefghijklmnopqrstuvwxyzabcdefghıjklmnopqrstuvwxyz0123456789.
Culture: az upper: ABCDEFGH?JKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.
Culture: az-Cyrl lower: abcdefghijklmnopqrstuvwxyzabcdefghıjklmnopqrstuvwxyz0123456789.
Culture: az-Cyrl upper: ABCDEFGH?JKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.
Culture: az-Cyrl-AZ lower: abcdefghijklmnopqrstuvwxyzabcdefghıjklmnopqrstuvwxyz0123456789.
Culture: az-Cyrl-AZ upper: ABCDEFGH?JKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.
Culture: az-Latn lower: abcdefghijklmnopqrstuvwxyzabcdefghıjklmnopqrstuvwxyz0123456789.
Culture: az-Latn upper: ABCDEFGH?JKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.
Culture: az-Latn-AZ lower: abcdefghijklmnopqrstuvwxyzabcdefghıjklmnopqrstuvwxyz0123456789.
Culture: az-Latn-AZ upper: ABCDEFGH?JKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.
Culture: tr lower: abcdefghijklmnopqrstuvwxyzabcdefghıjklmnopqrstuvwxyz0123456789.
Culture: tr upper: ABCDEFGH?JKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.
Culture: tr-CY lower: abcdefghijklmnopqrstuvwxyzabcdefghıjklmnopqrstuvwxyz0123456789.
Culture: tr-CY upper: ABCDEFGH?JKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.
Culture: tr-TR lower: abcdefghijklmnopqrstuvwxyzabcdefghıjklmnopqrstuvwxyz0123456789.
Culture: tr-TR upper: ABCDEFGH?JKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.
Diff: 16

The related code is here.

class SimpleNameToFileNameMapTraits : public NoRemoveSHashTraits< DefaultSHashTraits< SimpleNameToFileNameMapEntry > >
{
public:
typedef PCWSTR key_t;
static const SimpleNameToFileNameMapEntry Null() { SimpleNameToFileNameMapEntry e; e.m_wszSimpleName = nullptr; return e; }
static bool IsNull(const SimpleNameToFileNameMapEntry & e) { return e.m_wszSimpleName == nullptr; }
static key_t GetKey(const SimpleNameToFileNameMapEntry & e)
{
key_t key;
key = e.m_wszSimpleName;
return key;
}
static count_t Hash(const key_t &str) { return HashiString(str); }

inline ULONG HashiString(LPCWSTR szStr)
{
LIMITED_METHOD_CONTRACT;
ULONG hash = 5381;
while (*szStr != 0)
{
hash = ((hash << 5) + hash) ^ towupper(*szStr);
szStr++;
}
return hash;

The hash function for TPA lookup uses towupper() which is not recommanded to use for unicode characters.
https://www.man7.org/linux/man-pages/man3/towupper.3.html#NOTES

Could it be fixed to use HashString() for TPA lookup or is there a reason for using case insensitive hash function?

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Jun 11, 2020
@Dotnet-GitSync-Bot
Copy link
Collaborator

I couldn't figure out the best area label to add to this issue. Please help me learn by adding exactly one area label.

@ghost
Copy link

ghost commented Jun 12, 2020

Tagging subscribers to this area: @vitek-karas, @swaroop-sridhar
Notify danmosemsft if you want to be subscribed.

@swaroop-sridhar swaroop-sridhar added this to the 5.0 milestone Jun 12, 2020
@swaroop-sridhar swaroop-sridhar added area-AssemblyLoader-coreclr and removed untriaged New issue has not been triaged by the area owner labels Jun 12, 2020
@ghost
Copy link

ghost commented Jun 12, 2020

Tagging subscribers to this area: @vitek-karas
Notify danmosemsft if you want to be subscribed.

@vitek-karas
Copy link
Member

This is very likely the same issue as #37910 which has some more details on possible fixes.

@HJLeee
Copy link
Contributor Author

HJLeee commented Jun 15, 2020

Yes it is the same one. Let me participate in #37910. Thank you.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants