Files
sdk/runtime/vm
Vyacheslav Egorov a2ab7ccea4 [vm] Avoid UB in FinalizeHash(hash)
FinalizeHash(hash) was trying to avoid UB in expression 1 << 32
by casting 1 to uintptr_t. This type however is not wide enough
on 32-bit platforms.

Instead just use explicit comparison hashbits < kBitsPerInt32 to
avoid overflow in left shift.

This bug went unnoticed for a while because it the only place
where we call FinalizeHash(hash) is in the snapshot profile
writer code and it only triggers when gen_snapshot is a
32-bit binary - which is only true on Windows, as Mac and Linux
seem to use simarm_x64 configuration instead.

This UB was explicitly affecting the code behavior because C++
compiler would either optimize out or change behavior of any
code that consumed value produced by FinalizeHash(hash).

Fixes https://github.com/flutter/flutter/issues/97764

TEST=vm/cc/DirectChainedHashMap

Change-Id: I39f2b09e7516c875b765e5a065d1c1331f89fa33
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250741
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2022-07-06 12:48:16 +00:00
..
2021-07-13 01:55:45 +00:00
2021-07-13 01:55:45 +00:00
2022-01-20 00:57:57 +00:00
2022-01-20 00:57:57 +00:00
2022-01-20 00:57:57 +00:00
2022-01-20 00:57:57 +00:00
2022-01-20 00:57:57 +00:00
2022-01-20 00:57:57 +00:00
2022-01-20 00:57:57 +00:00
2022-03-25 10:29:30 +00:00
2022-06-10 15:48:54 +00:00
2022-01-20 00:57:57 +00:00
2022-01-20 00:57:57 +00:00
2021-07-09 13:48:25 +00:00
2021-11-16 16:23:36 +00:00
2022-01-21 21:24:20 +00:00
2022-01-21 21:24:20 +00:00
2022-07-06 12:48:16 +00:00
2022-01-20 00:57:57 +00:00
2022-01-20 00:57:57 +00:00
2022-01-20 00:57:57 +00:00
2022-05-24 09:10:51 +00:00
2022-03-25 10:29:30 +00:00
2022-03-25 10:29:30 +00:00
2022-03-26 09:41:21 +00:00
2022-01-20 00:57:57 +00:00
2022-06-28 16:02:53 +00:00
2022-07-04 07:53:39 +00:00
2022-01-20 00:57:57 +00:00
2022-06-15 11:08:28 +00:00
2022-01-20 00:57:57 +00:00
2022-01-20 00:57:57 +00:00
2022-04-25 23:12:53 +00:00
2021-06-14 20:45:18 +00:00
2021-06-14 20:45:18 +00:00
2022-01-20 00:57:57 +00:00
2022-01-20 00:57:57 +00:00
2021-10-14 00:10:12 +00:00