Fix race condition in test clock (backport #2819) #2821
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.
This Pull Request intends to fix the issue #2804
In order to do so, I first ran helgrind on the code, and found that there existed a race condition in a vector of booleans. Afterwards, I changed this vector to
std::atomic_bool
. With that, I ran the helgrind again, and found there was no more race condition.This is the full log of helgrind for the original code.
This is the full log of helgrind for the modified code.
Note that, since they are the full log of the helgrind, in both of these snippets, there are some unrelated warnings. However, by searching for
data race
inside this logs, it is possible to see that they were corrected.This is my first Pull Request, so if there are any changes I still have to do, please let me know.
(Edit: I just realized my signature in the commit was wrong. I believe I have corrected it, hopefully everything is OK now)
This is an automatic backport of pull request #2819 done by Mergify.