[mono] Use `unsigned char` when computing UTF8 string hashes (#21633)
commit3cb47d8b4dc0242665219e9b86825ebdaa43fb0c
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Mon, 13 Mar 2023 11:57:49 +0000 (13 12:57 +0100)
committerGitHub <noreply@github.com>
Mon, 13 Mar 2023 11:57:49 +0000 (13 12:57 +0100)
tree676ac008d60c51068e9cc294cb0cfdc27ec2beb1
parenta102a350e538ec510929912b0c05d76ee4360b2e
[mono] Use `unsigned char` when computing UTF8 string hashes (#21633)

Backport of https://github.com/dotnet/runtime/pull/83273 to mono/mono `2020-02`

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.

Contributes to https://github.com/dotnet/runtime/issues/82187
Contributes to https://github.com/dotnet/runtime/issues/78638
mono/eglib/ghashtable.c
mono/metadata/metadata.c