Skip to content

[2020-02] [mono] Use unsigned char when computing UTF8 string hashes#21633

Merged
akoeplinger merged 1 commit into2020-02from
backport/pr-21632-to-2020-02
Mar 13, 2023
Merged

[2020-02] [mono] Use unsigned char when computing UTF8 string hashes#21633
akoeplinger merged 1 commit into2020-02from
backport/pr-21632-to-2020-02

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Mar 11, 2023

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.

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
@akoeplinger akoeplinger merged commit 3cb47d8 into 2020-02 Mar 13, 2023
@akoeplinger akoeplinger deleted the backport/pr-21632-to-2020-02 branch March 13, 2023 11:57
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants