Repository navigation
Fix a run_loop future deadlock and an async_rw_mutex assertion - #8113
Conversation
A future made by make_future with a run_loop scheduler marked its operation as finished only after it had made the future ready. Making the future ready runs the continuations attached to it, so a continuation that called get() on that future ran the loop until the operation was finished, waiting for the receiver that was running the continuation. Mark the operation finished first; a waiter on another thread still waits in get() until the future is ready. Signed-off-by: Hartmut Kaiser <hartmut.kaiser@gmail.com>
If moving the value into the first shared state threw, the mutex kept that state without a value or an exception. Destroying the mutex then failed the assertion in the state's destructor, and a later access got a state without a value. Store the exception in the state, drop it and leave the mutex as it was before the access. Signed-off-by: Hartmut Kaiser <hartmut.kaiser@gmail.com>
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
Up to standards ✅🟢 Issues
|
This fixes two problems that the review of the 2.0.1 cherry-picks in #8099 found in code from #7891 and #7907. The same code is on master, so the fixes go here first and are then picked for 2.0.1 (#8074).
make_future.hpp): a future made bymake_futurewith arun_loopscheduler marked its operation as finished only after it had made the future ready. Making the future ready runs the attached continuations, so a continuation that calledget()on that future ran the loop until the operation was finished and waited forever for the receiver that was running it. 2.0.0 didn't have this problem; it came with Fix state machine race and deadlock in run_loop #7891. The receivers now mark the operation finished first. A waiter on another thread still waits inget()until the future is ready, and the receivers don't touch the loop after making the future ready.async_rw_mutex.hpp): if moving the value into the first shared state threw, the mutex kept that state without a value or an exception. Destroying the mutex then failed the assertion in the state's destructor (this was already the case in 2.0.0), and a later access got a state without a value. The state now gets the exception and is dropped, and the mutex is left as it was before the access.Each fix comes with a regression test:
test_run_loop_continuation_get(value, void and error, with the continuation attached throughkeep_future, asthen()runs the loop first) andtest_first_access_move_throw(read()andreadwrite()). Without the fixes the first test hangs and the second fails the assertion. With them the affected execution tests (run_loop, both async_rw_mutex tests, make_future, sender_future_error, both as_sender tests) pass in a Debug build with MSVC 19.44, the run_loop and async_rw_mutex tests with 1 to 16 threads.