Skip to content

Commit

Permalink
Ensure harvesterCounter 8-byte alignment (elastic#3273) (elastic#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.
  • Loading branch information
spacewrangler authored and tsg committed Jan 13, 2017
1 parent 1f6fe81 commit f6f5e10
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 @@ -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
Expand All @@ -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
}
Expand Down

0 comments on commit f6f5e10

Please sign in to comment.