-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In the original logic, when the future receiver completion is called, `__save_completion` and `__dispatch_result` both acquire and release the mutex. If the sequence is * Thread 1 calls `__save_completion`, sets `__data_`, then returns successfully. * Thread 2 calls the `__future` destructor, which acquires the mutex and sees that `__data_` is set, so it returns early, and since it still owns `__state_`, the future state is destroyed. * Thread 1 calls `__dispatch_result`, and attempts to access now freed memory. It's not clear why `__save_completion`/`__dispatch_result` acquire and release the mutex separately, so I combined the calls to both be done under the mutex. Additionally, there appeared to be a bug when setting the value/error into `__data_` raised an exception where `__dispatch_result` was never invoked, leading to the program to never complete. I added a test that waits indefinitely without this fix. Fixes #1413
- Loading branch information
Showing
2 changed files
with
36 additions
and
15 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
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