Open Quuxplusone opened 3 years ago
If the program would crash with O3 and Ok with O0, it should be a compiler bug. I would try to fix it. Thanks for reporting.
By the way, symmetric transfer isn't defined in the language standard. In N4878, it says:
If the type of await-suspend is std::coroutine_handle<Z>, await-suspend.resume() is evaluated
It didn't say anything about symmetric transfer and the style of symmetric transfer could prevent stack overflow.
This may not be related to this issue : ).
(In reply to Chuanqi Xu from comment #1)
> If the program would crash with O3 and Ok with O0, it should be a compiler
> bug. I would try to fix it. Thanks for reporting.
Great. Thank you very much :)
Even though the following code uses symmetric transfer, it crashes due to a stack-overflow. Please note that the code below is a minimal example to reproduce the stack-overflow: e.g., if I include the definition of the destructor of type
Type
in the header file, then I don't get a stack-overflow. The crash can also be reproduced when using the task<> type of the cppcoro library.I compile the code with
clang++-12 main.cc type.cc -std=c++20 -stdlib=libc++ -O3 -fsanitize=address
.Here is the output:
Interestingly, if I compile with
-O0
the program does not trigger a stack-overflow and exits without any errors.Further information about the problem and a workaround can be found here: https://stackoverflow.com/questions/67446478/symmetric-transfer-does-not-prevent-stack-overflow-for-c20-coroutines