-
Notifications
You must be signed in to change notification settings - Fork 30
Task.sleep(nanoseconds:)
causes a crash after resuming
#3646
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
Investigation Update (2021-10-10)I created a minimum reproducible LLVM IR code based on TaskSleep.swift. (At first, I used llvm-extract, but it doesn't help me because coroutine lowering assumes some inlinability and constantability of global metadata, so I did it by hand...) Here is the IR snippet to reproduce and simple test case to assert unreachable inst at the end of the function. From this investigation, I guess there is a root reason in LLVM. Based on print debugging, before and after of this line, unreachable basic blocks in the CFG are removed and also unreachable inst is added at the end of the function
I'll dig into the algorithm of |
Investigation Update (2021-10-11)At first, I forgot to mention that this issue is only reproduced with
From further investigation, that's because the call instruction at the end of BB calls a noreturn function directly, so it's ok to put unreachable here. In no-optimization mode, the callee function is not marked as noreturn, so Then, why the function is marked as noreturn only under optimization? That's because inlining and constant propagation help influencing the effect of the unreachable instruction emitted here The unreachable instruction has right semantics when it's put before I fixed this issue by putting |
closing this as resolved for now, or should we wait until upstream PR is merged and then propagated to the |
Somehow it doesn't work due to a mysterious unreachable instruction at the end of thunk function.
The minimal reproducible code and steps are here.
The unreachable instruction is located here.
At first, we should check if this could happen on Linux with coop global executor also. I've confirmed it doesn't happen on the main channel on Linux with coop, but have not confirmed for 5.5 release channel yet.
Update (2021-10-04)
The unreachable instruction is inserted here. But I don't understand the reason and LLVM coroutine intrinsic, so I'll learn around it https://github.com/apple/swift/blob/7eb0ca1d47d921d50631b1d74f2670b323d085ed/lib/IRGen/GenCall.cpp#L4932
The text was updated successfully, but these errors were encountered: