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

[v0.16.0] fix(pkg/counter): finish making counter atomic (#3276) #3284

Merged
merged 1 commit into from
Jun 28, 2023

Conversation

rafaeldtinoco
Copy link
Contributor

Last changes renamed Increment/Decrement to Increase/Decrease. This was reverted after discussions.

With this new approach:

  • Overflow is detected in both cases (and proved by test).
  • Thread safety is guaranteed by atomic Add/Sub operations.
  • Unit tests prove all assumptions and thread safety for all cases.
  • Benchmark tests can be used to test other approaches in the future.
  • Overflow of a sum of all given arguments isn't detected (avoid overhead).

NOTE: The issue is now fully fixed...

Originally, the bug was only about reading counter value in parallel to atomic operation (multiple LOAD/STORE simultaneously, and some not protected by atomics).

Previous fix, made by commit 1e54ce2, fixed data race but overflow errors could be reported more than once. It also had atomic operations for each given argument (if multiple arguments).

This version addresses all concerns.

commit: 0b97409 (main), cherry-pick

Last changes renamed Increment/Decrement to Increase/Decrease. This was
reverted after discussions.

With this new approach:

- Overflow is detected in both cases (and proved by test).
- Thread safety is guaranteed by atomic Add/Sub operations.
- Unit tests prove all assumptions and thread safety for all cases.
- Benchmark tests can be used to test other approaches in the future.
- Overflow of a sum of all given arguments isn't detected (avoid overhead).

NOTE: The issue is now fully fixed...

Originally, the bug was only about reading counter value in parallel to
atomic operation (multiple LOAD/STORE simultaneously, and some not
protected by atomics).

Previous fix, made by commit 1e54ce2, fixed data race but overflow errors
could be reported more than once. It also had atomic operations for each
given argument (if multiple arguments).

This version addresses all concerns.

commit: 0b97409 (main), cherry-pick
@rafaeldtinoco
Copy link
Contributor Author

@NDStrahilevitz note the last line:

commit: XXXX (where), what

when = main for now
what = backport or cherry-pick

if backport

[backport]

  • explanations

@rafaeldtinoco rafaeldtinoco changed the title fix(pkg/counter): finish making counter atomic (#3276) [v0.16.0] fix(pkg/counter): finish making counter atomic (#3276) Jun 28, 2023
Copy link
Collaborator

@NDStrahilevitz NDStrahilevitz left a comment

Choose a reason for hiding this comment

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

Format noted, i'll attempt the cherry-pick for #3285 if you don't mind. LGTM.

@rafaeldtinoco rafaeldtinoco merged commit 4b32dac into aquasecurity:v0.16.0 Jun 28, 2023
28 checks passed
@rafaeldtinoco rafaeldtinoco deleted the v0.16.0-cherry branch June 28, 2023 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants