[Bug c++/100897] Symmetric transfer does not prevent stack-overflow for C++20 coroutines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100897 --- Comment #3 from Iain Sandoe --- (In reply to Leonard von Merzljak from comment #2) > (In reply to Iain Sandoe from comment #1) > Thank you for your comment. I tried it out and can confirm that I don't get > a stack-overflow anymore if I omit -fsanitize=address and use an > optimization level > 1. So that's a workaround (on platforms that support indirect tail calls at all). > If the issues with coroutines and sanitizers are > already known, then this bug report can be marked as resolved. For the present, I will leave this open - until (at least) there's a chance to confirm the hypothesis and determine if the problems are the same ones as mentioned in other PRs. > Of course, it would be nice if the stack-overflow would not occur even when > using an optimization level <= 1, but this probably does not qualify as a > bug. Note that the inability to support indirect tail calls is not usually a failing in GCC - but that some platform ABIs cannot support it (e.g. because they require initialisation of some per DSO data). For platforms that support indirect tail calls, it is actually feasible to support the symmetric transfer at O0 (at least as per my local testing) - the front end can demand a tailcall "for correctness". The issue is that coroutines are not a target-specific implementation, and therefore demanding the tailcall will cause compile fails on targets that cannot support it. Of course, one can argue that the code will *probably* fail on those targets if there is arbitrary recursion needed - but it was decided to not to make this demand until a solution is found to supporting continuations on all target. JFTR, my outline sketch for this would be to allocate some area in the coroutine frame that is reserved for target-specific continuation support, and then to use a builtin to implement the continuation rather than relying on the indirect tailcall mechanism.
[Bug c++/100897] Symmetric transfer does not prevent stack-overflow for C++20 coroutines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100897 --- Comment #2 from Leonard von Merzljak --- (In reply to Iain Sandoe from comment #1) > for symmetric transfer to work without stack overflow, it relies on an > indirect tailcall. > > For some GCC targets indirect tail-calls are not available without some > additional support (see PR94794). > > I tried to reproduce this (with a test case I use regularly for this) on a > target that normally completes symmetric transfers successfully when the > optimisation level is > 1. (x86_64, darwin). > > The fail also occurs with my regular test case with -fsanitize=address - so, > it seems that the inclusion of the address sanitiser is preventing or > interfering with the tailcall. Note that there are also other known issues > with coroutines and the sanitizers (PR95137). Thank you for your comment. I tried it out and can confirm that I don't get a stack-overflow anymore if I omit -fsanitize=address and use an optimization level > 1. If the issues with coroutines and sanitizers are already known, then this bug report can be marked as resolved. Of course, it would be nice if the stack-overflow would not occur even when using an optimization level <= 1, but this probably does not qualify as a bug.
[Bug c++/100897] Symmetric transfer does not prevent stack-overflow for C++20 coroutines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100897 Iain Sandoe changed: What|Removed |Added Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed||2021-06-11 See Also||https://gcc.gnu.org/bugzill ||a/show_bug.cgi?id=94794, ||https://gcc.gnu.org/bugzill ||a/show_bug.cgi?id=95137 --- Comment #1 from Iain Sandoe --- for symmetric transfer to work without stack overflow, it relies on an indirect tailcall. For some GCC targets indirect tail-calls are not available without some additional support (see PR94794). I tried to reproduce this (with a test case I use regularly for this) on a target that normally completes symmetric transfers successfully when the optimisation level is > 1. (x86_64, darwin). The fail also occurs with my regular test case with -fsanitize=address - so, it seems that the inclusion of the address sanitiser is preventing or interfering with the tailcall. Note that there are also other known issues with coroutines and the sanitizers (PR95137).