Files
sdk/runtime/platform
Vyacheslav Egorov f999e15653 [vm] Avoid UB in CompressedStackMap payloads
Having uint32_t field in UntaggedCompressedStackMaps::Payload
implies 4 byte alignment of the whole structure and the field
itself. We would prefer, however, to avoid this requirement because
we are packing these structures tight in AOT snapshots without any
padding in between.

This change rewrites the implementation to use `memcpy(...)` to remove
any alignment requirements. Note that this `memcpy(...)` will
be optimized down to a single memory move on all platforms we currently
support as they support necessary unaligned load/store instructions.

This also means that the original code worked just fine, except when
running under UBSAN.

Fixes https://github.com/dart-lang/sdk/issues/47971

TEST=ubsan bots

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-ubsan-linux-release-x64-try,vm-kernel-ubsan-linux-release-x64-try
Change-Id: I26a30123fcbc6d2c711f039f15f749913ce4d7bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226100
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-01-04 08:33:15 +00:00
..
2020-05-07 19:40:18 +00:00
2020-05-07 19:40:18 +00:00