Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure harvesterCounter 8-byte alignment (#3273) #3338

Merged
merged 2 commits into from
Jan 13, 2017

Conversation

spacewrangler
Copy link
Contributor

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.

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.
@elasticmachine
Copy link
Collaborator

Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run.

1 similar comment
@elasticmachine
Copy link
Collaborator

Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run.

@ruflin
Copy link
Contributor

ruflin commented Jan 11, 2017

jenkins, test it

Copy link
Contributor

@ruflin ruflin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add an entry to the changelog under Added

@@ -21,6 +21,7 @@ var (
)

type Prospector struct {
harvesterCounter uint64 // Must be 8-byte aligned. Ensured if first field in struct
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it is quite likely that this is changed by accident in the future, I suggest to add a comment on top of the variable with the following content:

// harvesterCount MUST be first field in struct. See golang/go#599

Copy link
Contributor Author

@spacewrangler spacewrangler Jan 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback @ruflin. Should I make the changelog entry under Added or Bugfixes? I know you wrote Added above but thought I'd double check since this is a bug fix.

Also, I agree this is brittle. I.e. someone could easily break this by changing the order of the fields. Should we add a test for this? I realize we may address the issue more generally per @urso's comment #3273 (comment) but not sure what the priority of that is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine putting it under Bugfixes.

Do you have some ideas on how to add a test? Would be great to have one.

@tsg tsg added Filebeat Filebeat and removed Metricbeat Metricbeat labels Jan 13, 2017
@tsg tsg merged commit fd64af2 into elastic:master Jan 13, 2017
@tsg
Copy link
Contributor

tsg commented Jan 13, 2017

Thanks @spacewander for the fix! As we have a little bit of urgency around this, I merged it as is and will add the changelog in a follow up PR.

@tsg tsg added the needs_backport PR is waiting to be backported to other branches. label Jan 13, 2017
tsg pushed a commit to tsg/beats that referenced this pull request Jan 13, 2017
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)
@tsg tsg removed the needs_backport PR is waiting to be backported to other branches. label Jan 13, 2017
ruflin pushed a commit that referenced this pull request Jan 13, 2017
* 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 fd64af2)

* Follow up with changelog for 3338 (#3363)

(cherry picked from commit 03b70c3)
@spacewrangler spacewrangler deleted the fix/3273-64bit-alignment branch January 14, 2017 00:44
@spacewrangler spacewrangler restored the fix/3273-64bit-alignment branch January 14, 2017 01:07
@spacewrangler spacewrangler deleted the fix/3273-64bit-alignment branch January 16, 2017 00:10
leweafan pushed a commit to leweafan/beats that referenced this pull request Apr 28, 2023
* Ensure harvesterCounter 8-byte alignment (elastic#3273) (elastic#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 f6f5e10)

* Follow up with changelog for 3338 (elastic#3363)

(cherry picked from commit 6af51cd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants