-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[bug] clang incorrectly uses coroutine frame for scratch space after suspending (take 2) #65054
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
Comments
@llvm/issue-subscribers-coroutines |
To be clear, this isn't new in b32aa72 (I can reproduce it back at As previously discussed, it seems like clang needs to directly implement a more principled rule, something like "treat the coroutine frame as having escaped (or having been deallocated) at the suspend point". |
This is a little bit different from the alias issue. That was workarounded by the previous fix. The problem of the issue may be that part of the semantics depends on some optimizations implicitly. This is a little bit tough to handle... |
The direct issue is still the call to And as a short-term workaround, we probably can mark |
Thanks for the quick fix! |
Please consider backporting to 17.0.x. |
This is a regression so it won't be in 17.x |
The fix was backported (f05226d), no? Or I'm confusing bugs? |
That was backported but I feel it is not so stable. So I send another PR to revert it in 17.x. So these bugs wouldn' |
Starting a new thread for this, because the previous threads have become long and confused by rollbacks and cherrypicks. Previous history here:
[bug] clang miscompiles coroutine awaiter, moving write across a critical section #56301: this issue was fixed for a reproducer I filed, but not for all programs/optimization levels (see below).
[bug] clang incorrectly uses coroutine frame for scratch space after suspending #65018: a regression caused by the first try at fixing [bug] clang miscompiles coroutine awaiter, moving write across a critical section #56301. It was fixed by reverting.
I've found another case where clang incorrectly writes to the coroutine frame after suspending, introducing a data race. To recap, clang must not write to the coroutine frame after suspending, because another thread may have already resumed/destroyed the coroutine by the time the write happens.
Here is the program, a slight variant of the one in #65018 (with a fix for the "caller always leaks" issue discussed in #65030):
(Compiler Explorer)
Compiler Explorer isn't yet up to date with recent commits, but I built clang manually at b32aa72 and then ran
./bin/clang -std=c++20 -O0 -S -masm=intel foo.cc
. This gives me the following output:@ChuanqiXu9
The text was updated successfully, but these errors were encountered: