Align bins_space_ storage (#17552)

Otherwise, `new (BinFromIndex(b)) Bin(this, bin_size);` in bfc_arena.cc
would cause a -fsanitize=alignment (part of -fsanitize=undefined)
failure like

runtime error: constructor call on misaligned address 0xXXX for type
'Bin', which requires 8 byte alignment
This commit is contained in:
Fangrui Song 2024-02-11 19:18:26 -08:00 committed by GitHub
parent 1182b5509b
commit d00adb7989
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -482,7 +482,7 @@ class BFCArena : public IAllocator {
Bin* BinForSize(size_t bytes) { return BinFromIndex(BinNumForSize(bytes)); }
char bins_space_[sizeof(Bin) * kNumBins];
alignas(Bin) char bins_space_[sizeof(Bin) * kNumBins];
// The size of the current region allocation.
SafeInt<size_t> curr_region_allocation_bytes_;