lewissbaker / lewissbaker.github.io

Lewis Baker's Blog

Home Page:https://lewissbaker.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Discussion for Understanding Symmetric Transfer

lewissbaker opened this issue · comments

Comments and questions welcome on the post C++ Coroutines: Understanding Symmetric Transfer

See also discussion thread on /r/cpp

commented

Thank you for this very interesting post. I'm using the cppcoro library and have the problem that I get a stack-overflow even though I use symmetric transfer. I created a minimal reproducible example and posted a question on stack-overflow: Symmetric transfer does not prevent stack-overflow for C++20 coroutines. I you have time could you please take a look at this question. Thank you very much in advance.

This post is extremely good, talking this complicated topic in great detail. Helping guys who do not familiar with the detail of coroutine likes me a lot!

I have a question is that in the section of "Visualising the stack" (i.e. after changing to use symmetric transfer), I think the stack frames of coroutine_handle::resume() still keep accumulating while the stack frame of coroutine body or $resume will be popped properly. Because every time doing the symmetric transfer, there is a function call to returned_handle_from_await_suspend.resume() which won't be popped when symmetric transferring.

Or if the stack frame of .resume() and the $resume is actually the same one ? You just split them in the visualization for clarity.

After reading the next post of understanding the compiler transform, I find the answer to my question. The compiler may not actually call the resume() on the returned_handle_from_await_suspend, it can use the "trampoline loop" and could avoid the accumulation of .resume() stack frame.