[SDK] Valgrind errors on std::atomic variables #2244
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2243
Changes
Using only the default constructor to initialize
std::atomic
objects is incorrect.This is a particularity of
std::atomic
itself, that does not follow the same rules as C++ in general.See: https://en.cppreference.com/w/cpp/atomic/atomic/atomic
In the entire code base, reviewed every use of
std::atomic
,and changed initialization to use the direct list initialization syntax.
see: https://en.cppreference.com/w/cpp/language/list_initialization
This form is the most robust and maintainable:
This fixed the bug reported on the periodic metric reader, tested under valgrind.
This fixed a missing initialization in one of the
BatchLogRecordProcessor
constructors,found by code review.
This also fixed the following pattern, which technically, is incorrect:
With the fix, code such as:
is correct, because it is now legal to call
store()
as the object is initialized.CHANGELOG.md
updated for non-trivial changes