Fix thread safety bug in split sender notify#1361
Merged
ericniebler merged 1 commit intoNVIDIA:mainfrom Jul 6, 2024
Merged
Conversation
ccotter
commented
Jul 5, 2024
|
|
||
| STDEXEC_ASSERT(__waiters_copy.front() != __get_tombstone()); | ||
| for (__local_state_base* __item: __waiters_copy) { | ||
| for (auto __itr = __waiters_copy.begin(); __itr != __waiters_copy.end(); ) { |
Contributor
Author
There was a problem hiding this comment.
I didn't find this fix all that satisfying (it seems a little too "cute"). Open to suggestions here. I considered changing the intrusive slist to handle this better, since the intrusive nature of the data structure leaves the iterator open to such bugs, but that didn't seem like the right thing to do.
Contributor
Author
|
If we find any more bugs with the "split is thread-safe" test, we'll need to consider renaming the test! |
Notifying the `local_state` might cause it to be destructed, whiich means the instrusive list's increment might be accessing uninitialized memory. Fixes NVIDIA#1354 Test plan: I was able to fairly reliably reproduce the TSAN and MSAN diagnostics by defining `local_state_base`'s destructor to set `__next_=nullptr` and adding a `sleep(25ms)` as the first line in `__notify_waiters`. With the fix, I could run the TSAN and MSAN executables for a few minutes and never saw any errors.
ericniebler
approved these changes
Jul 5, 2024
Collaborator
|
/ok to test |
Contributor
Author
|
The CI failure seems unrelated? |
Collaborator
|
THANK YOU so much for finding an fixing this bug. 🎉
yes, unrelated. it only happens with nvc++. i haven't gotten to the bottom of it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Notifying the
local_statemight cause it to be destructed, whiich means the instrusive list's increment might be accessing uninitialized memory.Fixes #1354
Test plan: I was able to fairly reliably reproduce the TSAN and MSAN diagnostics by defining
local_state_base's destructor to set__next_=nullptrand adding asleep(25ms)as the first line in__notify_waiters. With the fix, I could run the TSAN and MSAN executables for a few minutes and never saw any errors.