From 47c9be00d12211448064501c56fc2b7a42ce6e1b Mon Sep 17 00:00:00 2001 From: Denis Shemanaev Date: Tue, 7 Jan 2025 16:15:07 +0300 Subject: [PATCH] Fixed 64-bit alignment panic on 32-bit platforms --- section_inverted_text_index.go | 7 ++++--- segment.go | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/section_inverted_text_index.go b/section_inverted_text_index.go index db7b1a91..21fe0031 100644 --- a/section_inverted_text_index.go +++ b/section_inverted_text_index.go @@ -915,6 +915,8 @@ func (i *invertedTextIndexSection) InitOpaque(args map[string]interface{}) reset } type invertedIndexOpaque struct { + bytesWritten uint64 // atomic access to this variable, moved to top to correct alignment issues on ARM, 386 and 32-bit MIPS. + results []index.Document chunkMode uint32 @@ -967,9 +969,8 @@ type invertedIndexOpaque struct { fieldAddrs map[int]int - bytesWritten uint64 - fieldsSame bool - numDocs uint64 + fieldsSame bool + numDocs uint64 } func (io *invertedIndexOpaque) Reset() (err error) { diff --git a/segment.go b/segment.go index 41abde25..fce550cf 100644 --- a/segment.go +++ b/segment.go @@ -89,6 +89,10 @@ func (*ZapPlugin) Open(path string) (segment.Segment, error) { // SegmentBase is a memory only, read-only implementation of the // segment.Segment interface, using zap's data representation. type SegmentBase struct { + // atomic access to these variables, moved to top to correct alignment issues on ARM, 386 and 32-bit MIPS. + bytesRead uint64 + bytesWritten uint64 + mem []byte memCRC uint32 chunkMode uint32 @@ -105,10 +109,6 @@ type SegmentBase struct { fieldDvNames []string // field names cached in fieldDvReaders size uint64 - // atomic access to these variables - bytesRead uint64 - bytesWritten uint64 - m sync.Mutex fieldFSTs map[uint16]*vellum.FST