Page MenuHomePhabricator

prevector: avoid misaligned member accesses
ClosedPublic

Authored by Fabien on May 6 2020, 21:31.

Details

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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien requested review of this revision.May 6 2020, 21:31

[Bot Message]
One or more PR numbers were detected in the summary.
Links to those PRs have been inserted into the summary for reference.

This revision is now accepted and ready to land.May 6 2020, 22:31