Skip to content

Commit

Permalink
Fix undefined behavior in experimental::coro
Browse files Browse the repository at this point in the history
Set the cancel member for different coro executors.
Fixes chriskohlhoff#1536
  • Loading branch information
terrakuh committed Oct 3, 2024
1 parent efdc25a commit a744b72
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions asio/include/asio/experimental/impl/coro.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,7 @@ struct coro<Yield, Return, Executor, Allocator>::awaitable_t
{
st->second.state = cancellation_state(
st->second.slot = st->first.slot());
coro_->cancel = &st->second;
}

E e;
Expand All @@ -1021,6 +1022,10 @@ struct coro<Yield, Return, Executor, Allocator>::awaitable_t
hp.cancel->state.slot().template emplace<cancel_handler>(
coro_.get_executor(), coro_);
}
else
{
coro_.coro_->cancel = hp.cancel;
}

auto hh = detail::coroutine_handle<
detail::coro_promise<Yield, Return, Executor, Allocator>>::from_promise(
Expand Down

0 comments on commit a744b72

Please sign in to comment.