Skip to content

Commit

Permalink
Ensure harvesterCounter 8-byte alignment (elastic#3273)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
spacewrangler authored Jan 8, 2017
1 parent d1fe6ef commit 8b99044
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion filebeat/prospector/prospector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,7 +31,6 @@ type Prospector struct {
states *file.States
wg sync.WaitGroup
channelWg sync.WaitGroup // Separate waitgroup for channels as not stopped on completion
harvesterCounter uint64
}

type Prospectorer interface {
Expand Down

0 comments on commit 8b99044

Please sign in to comment.