From fd64af2d8fc9e3e76f9fe433e02935af7229a41c Mon Sep 17 00:00:00 2001 From: Jon Langdon Date: Fri, 13 Jan 2017 00:57:14 -0800 Subject: [PATCH] Ensure harvesterCounter 8-byte alignment (#3273) (#3338) harvesterCounter is accessed atomically and will fault on x86-32 or ARM if not 8-byte aligned. See golang/go#599 for more details on why it fails and https://golang.org/pkg/sync/atomic/#pkg-note-BUG for how putting the field first in the struct fixes it. --- filebeat/prospector/prospector.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filebeat/prospector/prospector.go b/filebeat/prospector/prospector.go index bab3e3db7c09..790baacbfd33 100644 --- a/filebeat/prospector/prospector.go +++ b/filebeat/prospector/prospector.go @@ -23,6 +23,7 @@ var ( ) type Prospector struct { + harvesterCounter uint64 // Must be 8-byte aligned. Ensured if first field in struct cfg *common.Config // Raw config config prospectorConfig prospectorer Prospectorer @@ -32,7 +33,6 @@ type Prospector struct { states *file.States wg sync.WaitGroup channelWg sync.WaitGroup // Separate waitgroup for channels as not stopped on completion - harvesterCounter uint64 ID uint64 Once bool }