-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
std: Partial fix for #33368 #33408
std: Partial fix for #33368 #33408
Conversation
This partially fixes a problem with `std::panic::catch_unwind` not being compatible with coroutines due to holding onto a thread-local reference across a user providden callback.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @aturon (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
As I mentioned before, this is not sufficient for actually getting coroutines to work with the standard library. Any usage of TLS can end up causing segfaults in a program with coroutines due to LLVM's optimizations today. The hack of |
Ah damn... You're right. Right about everything. I'm really sorry about that. So what should I do now? Mark But I do have to say that even if we would make TLS access Original comment(s):
|
cc @rust-lang/libs This thread is highlighting a policy issue we should discuss. Do others on the libs team have thoughts? |
cc @rust-lang/lang as well. |
It seems that it is impossible to use Rust to develop any Coroutine libraries now, because it is impossible to bypass the libstd!!! With the current libstd design, we cannot switch contexts because it will crash everything. Or maybe we can fork a libstd to build our own version of that? |
|
Oh and I'd like to highlight that a matching issue already exists: #33368 As I said: There are a couple solutions for this and implementing one of them would be quite advantageous for Rust to be adopted for server software. This PR might still be useful depending on the outcome though. |
☔ The latest upstream changes (presumably #32900) made this pull request unmergeable. Please resolve the merge conflicts. |
The libs team discussed this PR during triage yesterday, and the conclusion was that we probably don't want to merge this at this time. We decided that we're amenable to supporting coroutines in the standard library perhaps one day (so long as it comes at no cost to other users), but this is unfortunately not enough to actually fix compatibility in the standard library itself (TLS is overall a major problem). As a result we don't want to take piecemeal PRs like this for now which fix bugs as they come up, but rather fix the problem at the source (TLS in this case). For now I'm going to close this in light of that decision, and we can continue discussion on #33368 |
Ah, and one other things I forgot to mention. A great fix for this would be to actually just not use TLS at all here. That's somewhat costly in terms of the overhead of catch_panic, so getting rid of that would be great entirely! (may be tricky though) |
@alexcrichton Thanks for taking your time for this (now) useless PR. I'm sorry for that. 😅 |
This partially fixes a problem with
std::panic::catch_unwind
not being compatible with coroutines due to holding onto a thread-local reference across a user providden callback.Thanks @arielb1!
Note: Unfortunately I was incapable of testing this PR because compilation of librustc failed for some reason and I couldn't figure out why.