Skip to content

Commit

Permalink
Ensure harvesterCounter 8-byte alignment (#3273) (#3338)
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.
(cherry picked from commit fd64af2)
  • Loading branch information
spacewrangler authored and Tudor Golubenco committed Jan 13, 2017
1 parent fed391d commit ff009ed
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 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,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 {
Expand Down

0 comments on commit ff009ed

Please sign in to comment.