[2020-02] [mono] Use unsigned char when computing UTF8 string hashes#21633
Merged
akoeplinger merged 1 commit into2020-02from Mar 13, 2023
Merged
[2020-02] [mono] Use unsigned char when computing UTF8 string hashes#21633akoeplinger merged 1 commit into2020-02from
unsigned char when computing UTF8 string hashes#21633akoeplinger merged 1 commit into2020-02from
Conversation
The C standard does not specify whether `char` is signed or unsigned, it is implementation defined. Apparently Android aarch64 makes a different choice than other platforms (at least macOS arm64 and Windows x64 give different results). Mono uses `mono_metadata_str_hash` in the AOT compiler and AOT runtime to optimize class name lookup. As a result, classes whose names include UTF-8 continuation bytes (with the high bit = 1) will hash differently in the AOT compiler and on the device. Fixes dotnet/runtime#82187 Fixes dotnet/runtime#78638
vargaz
approved these changes
Mar 11, 2023
jonpryor
added a commit
to jonpryor/xamarin-android
that referenced
this pull request
May 19, 2023
Fixes: dotnet#7658 Changes: mono/mono@6dd9def...73df89a * mono/mono@73df89a73d2: Fix xar url again * mono/mono@36fd1837d0d: Switch back to original xar version * mono/mono@5bbc709e5dc: Fix xar download url * mono/mono@3cb47d8b4dc: [mono] Use `unsigned char` when computing UTF8 string hashes (mono/mono#21633) * mono/mono@a102a350e53: [2020-02] [mono][loader] Set status on success; avoid mmap on Android (mono/mono#21610) * mono/mono@74f85c2ac33: Fix url to gtksharp msi * mono/mono@2f7d584ad2b: Fix build on macOS 13 / Xcode 14 (mono/mono#21597) * mono/mono@03b09960787: Disable a failing test
jonpryor
added a commit
to dotnet/android
that referenced
this pull request
May 25, 2023
Fixes: #7658 Changes: mono/mono@6dd9def...73df89a * mono/mono@73df89a73d2: Fix xar url again * mono/mono@36fd1837d0d: Switch back to original xar version * mono/mono@5bbc709e5dc: Fix xar download url * mono/mono@3cb47d8b4dc: [mono] Use `unsigned char` when computing UTF8 string hashes (mono/mono#21633) * mono/mono@a102a350e53: [2020-02] [mono][loader] Set status on success; avoid mmap on Android (mono/mono#21610) * mono/mono@74f85c2ac33: Fix url to gtksharp msi * mono/mono@2f7d584ad2b: Fix build on macOS 13 / Xcode 14 (mono/mono#21597) * mono/mono@03b09960787: Disable a failing test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #21632 to 2020-02
/cc @lambdageek
Backport of dotnet/runtime#83273 to mono 2020-02
Contributes to #82187
Contributes to #78638
Customer Impact
Resolves crashes in Release builds of Android apps that include classes with non-ASCII names that use AOT compilation.
Testing
Manual testing. New regression test.
Risk
Low. For code that uses ASCII names the hash code computation is unchanged.