From ff009ed1873fad17a15034e681c64a5d4befd4b1 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. (cherry picked from commit fd64af2d8fc9e3e76f9fe433e02935af7229a41c) --- filebeat/prospector/prospector.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/filebeat/prospector/prospector.go b/filebeat/prospector/prospector.go index 93277430b04..6cca988b14b 100644 --- a/filebeat/prospector/prospector.go +++ b/filebeat/prospector/prospector.go @@ -21,6 +21,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 @@ -30,7 +31,8 @@ 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 } type Prospectorer interface {