Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discussion for Understanding Symmetric Transfer #5

Open
lewissbaker opened this issue May 12, 2020 · 4 comments
Open

Discussion for Understanding Symmetric Transfer #5

lewissbaker opened this issue May 12, 2020 · 4 comments

Comments

@lewissbaker
Copy link
Owner

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

@lewissbaker
Copy link
Owner Author

See also discussion thread on /r/cpp

@L-v-M
Copy link

L-v-M commented May 8, 2021

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.

@huang-jl
Copy link

huang-jl commented Feb 15, 2023

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.

@huang-jl
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants