From d8e82691ce37ad2d40f8d7ddfdff9a361a0e55e8 Mon Sep 17 00:00:00 2001 From: "The gemma.cpp Authors" Date: Thu, 15 Oct 2026 10:59:15 -0700 Subject: [PATCH] Do not apply #pragma pack(1) to NuqStream::AlignedMatrix and ClusterBuf. `#pragma pack(push, 1)` on `NuqStream` currently encloses the nested helper classes `AlignedMatrix` and `ClusterBuf`, which contain `hwy::AlignedFreeUniquePtr` (`std::unique_ptr`) members and are allocated as normal working buffers during compression rather than packed into the bitstream. Under `#pragma pack(1)`, `ClusterBuf::argmin` is placed at a non-8-byte-aligned offset on 64-bit targets, triggering `-fsanitize=alignment` on member calls to `std::unique_ptr`. PiperOrigin-RevId: 1000251482 --- compression/types.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compression/types.h b/compression/types.h index 429865bc..d38ed542 100644 --- a/compression/types.h +++ b/compression/types.h @@ -168,6 +168,7 @@ struct NuqStream { // smaller size (table amortized over more weights). static constexpr size_t kGroupSize = 256; +#pragma pack(pop) // Storage for dynamic programming. There are two matrices; we use separate // allocations to avoid type punning. template @@ -200,6 +201,7 @@ struct NuqStream { AlignedMatrix costs; AlignedMatrix argmin; }; +#pragma pack(push, 1) // Returns offset of packed indices from the start of the stream. This matches // the (padded) total table size because table entries are bytes.