Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upBug: Incompatibility of Rust's stdlib #56
Comments
zonyitoo
added
bug
help wanted
labels
May 15, 2016
This was referenced Jul 5, 2016
This comment has been minimized.
This comment has been minimized.
|
how much it affects real-world applications? is there any way to check if given project is affected by imporper TLS handling? |
This comment has been minimized.
This comment has been minimized.
|
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"); |
This comment has been minimized.
This comment has been minimized.
|
seems there is no short-term workaround either? I think it should be mentioned in README in both coio-rs and mioco. |
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
ihrwein
commented
Jun 16, 2017
|
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 |
This comment has been minimized.
This comment has been minimized.
|
If Goroutines were in Rust it would be a pure awesomeness |
This comment has been minimized.
This comment has been minimized.
|
futures-await goes in this direction. |
This comment has been minimized.
This comment has been minimized.
|
Also: rust-lang/rfcs#2033 |
This comment has been minimized.
This comment has been minimized.
|
@ihrwein Thanks for your suggestion. What you are proposing is "coroutine local variable", which stores data with the |
This comment has been minimized.
This comment has been minimized.
|
I wrote down my thoughts about this here: rust-lang/rfcs#2033 (comment) |
zonyitoo
referenced this issue
Dec 24, 2017
Closed
Undefined behavior invoked by moving stacks between threads #6
This comment has been minimized.
This comment has been minimized.
aep
commented
Jul 6, 2018
•
|
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. |
This comment has been minimized.
This comment has been minimized.
|
Yup. I have already figure out. This is nothing to do with the TLS inlining. |
This comment has been minimized.
This comment has been minimized.
|
|
zonyitoo commentedMay 15, 2016
This bug was originally found in #53 . The reason was: stdlib uses a
PANIC_COUNTin 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_COUNTpartially 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.