You have to use something similar to https://github.com/facebook/folly/tree/main/folly/experiment... to solve this problem.
It's a nasty bug that everyone encounters when first working with coroutines. (Similarly everyone will encounter references that don't live until you co_await the task).