-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As reported in #577, #578 didn't fix the UB in cancelled tasks. There were two bugs in that "fix": 1. we were writing the coroutine handle to resume *after* synchronizing between the two racing operation states, leading to a data race when the deferred stop source completed second; and 2. it's wrong to call `continuation_.done()` to store the coroutine handle to be resumed later because `done()` completes the operation with `set_done()` as a side effect. This diff fixes both issues. Instead of storing a coroutine handle to be resumed, we store an enum value that describes which coroutine handle to resume (so we don't eagerly invoke `done()`), and we do the store before synchronizing to eliminate the data race. I've added a unit test that fails with a TSAN-detected data race without the fix, and the fix silences the TSAN error. I also clang-formatted `task.hpp` and the modified test file.
- Loading branch information
Showing
2 changed files
with
122 additions
and
73 deletions.
There are no files selected for viewing
This file contains 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
Oops, something went wrong.