From d00adb7989635a4046d896fab6358ad4c7b695db Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 11 Feb 2024 19:18:26 -0800 Subject: [PATCH] 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 --- onnxruntime/core/framework/bfc_arena.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onnxruntime/core/framework/bfc_arena.h b/onnxruntime/core/framework/bfc_arena.h index e16b90ded3..5e4cd9f62f 100644 --- a/onnxruntime/core/framework/bfc_arena.h +++ b/onnxruntime/core/framework/bfc_arena.h @@ -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 curr_region_allocation_bytes_;