-
Notifications
You must be signed in to change notification settings - Fork 31
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
Bug: Incompatibility of Rust's stdlib #56
Comments
how much it affects real-world applications? is there any way to check if given project is affected by imporper TLS handling? |
Unfortunately, I think every existing projects in Rust will be affected. Because nearly every Rust projects uses libstd, and libstd uses TLS for
So, for example, if someone's project has println!("Print something");
// ...
Scheduler::sched();
// ...
println!("Print, but possibly crash"); |
seems there is no short-term workaround either? I think it should be mentioned in README in both coio-rs and mioco. |
It seems that someone is going to add coroutine support directly to LLVM, which means that it is possible to tell LLVM not to inline TLS calls between context swaps. https://internals.rust-lang.org/t/llvm-coroutines-to-bring-awarness |
First of all, thanks for the great work what you put into this library. I played with I tried to compile coio but one if its dependency became outdated and today's Rust compiler won't accept it (owning_ref, maybe). I read the long issue in the std library that TLS should be eliminated from std to support coroutines. I don't have the knowledge to add any value to that conversation, but FYI LLVM 4.0 has experimental coroutine support, which may help. Somebody wrote that TLS is just a hidden extra parameter to functions. According to this link, an extra I may have another idea: if a TLS is accessed from a coroutine, then the TLS is not placed into |
If Goroutines were in Rust it would be a pure awesomeness |
futures-await goes in this direction. |
Also: rust-lang/rfcs#2033 |
@ihrwein Thanks for your suggestion. What you are proposing is "coroutine local variable", which stores data with the |
I wrote down my thoughts about this here: rust-lang/rfcs#2033 (comment) |
Isn't this a matter of just not inlining TLS access? Might be a little too late here since rust is headed to standardizing futures, but I wrote an entire linker https://github.com/aep/elfkit which can easily be adapted to support a different TLS strategy. |
Yup. I have already figure out. This is nothing to do with the TLS inlining. |
|
This bug was originally found in #53 . The reason was: stdlib uses a
PANIC_COUNT
in TLS to ensure no panic while panicking in runtime. But obviously, Coroutines in coio can be migrated between threads, which means that it turns out to cause data race (because compiler still think that we are running in the same thread, so we may access to the other thread's TLS without any synchronization method).We wanted to solve this
PANIC_COUNT
partially in rust-lang/rust#33408, but because stdlib relies heavily on TLS (such asprintln!
), it will also causes SIGSEGV randomly:Rust's compiler don't know that we have switched to another thread, so it may inline those TLS calls.
We are looking for a solution for this bug, discussing in here, if you have any idea, please help.
The text was updated successfully, but these errors were encountered: