HomePhabricator

prevector: avoid misaligned member accesses

Description

prevector: avoid misaligned member accesses

Summary:

`#pragma pack(1)` prevents aligning the struct and its members to their
required alignment. This can result in code that performs non-aligned
reads and writes to integers and pointers, which is problematic on some
architectures.

It also triggers UBsan — see
  https://github.com/bitcoin/bitcoin/pull/17156#issuecomment-543123631
and #17510.

Backport of core PR17708.

Test Plan:
With and without UBSAN:

ninja check

Reviewers: #bitcoin_abc, nakihito

Reviewed By: nakihito

Differential Revision: https://reviews.bitcoinabc.org/D5986

Details

Provenance
Anthony Towns <aj@erisian.com.au>Authored on Dec 10 2019, 07:05
FabienCommitted on May 7 2020, 07:34
FabienPushed on May 7 2020, 07:35
Reviewer
nakihito
Differential Revision
D5986: prevector: avoid misaligned member accesses
Parents
rABC580150a9f863: [Automated] Update timing.json
Branches
Unknown
Tags
Unknown