-
Notifications
You must be signed in to change notification settings - Fork 43
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
Using Thread local storage is unsafe #31
Comments
WOW.... That's true. Do you have any good ideas? |
One of my suggestion is spawn(move|env: &mut Environemnt| {
// Pass the environment into the coroutine
}); But one of our goal is to implement M:N model, so this may not work... |
I think I have a scheme that will work. It requires changes + new API in the standard library, but does not break the standard library. Rust adds a borrow count to the TLS structure. Every time a When a coroutine is called, before the stack switch the borrow count is read. When the coroutine There are one of two ways to expose this to the API user. First, you can |
That looks good. But I don't think Rust team will accept this change, because they are not going to support this kind of stackful coroutines in the language. This really is a problem. @doomsplayer Do you have any idea? |
Taking mid term exams these days.I'll consider this later. On 2015年5月2日周六 上午1:43 Y. T. CHUNG [email protected] wrote:
|
I think this is, unfortunately, just "expected behavior" given the state of Clang. It's a known issue but has not been fixed / addressed. MSVC has a /GT flag which prevents caching of the TLS addresses. Is there a way to ban the |
@polyfractal I just thought about your second idea today. Provide a customized macro, such as One radical solution, as discussed with @doomsplayer, is to rewrite the whole |
@zonyitoo Maybe we have to reject Another thing is We can add own |
@deniskolodin Well, forbidding I am fully aware that using TLS is very unsafe, which is critical in zonyitoo/coio-rs#56 . |
This is probably not the only api that is affected.
Right now:
with
block.Because of this, it is easy to build a simple test case that violates TLS rules.
This will print:
The text was updated successfully, but these errors were encountered: