Reference cycle bug in Rust's scoped threads
github.com
github.com
The specific API chosen, however, used RAII guards to "guarantee" that the parent thread joined on the child thread within a certain scope. Unfortunately, it's possible to subvert the RAII guard by placing it within a ref-counted cycle, which results in its destructor never being run.
For the moment, the API is being moved back to "unstable" status.
We are considering a variety of ways to address the problem, including:
* Avoiding RAII guards in the API, instead using explicit closures to guarantee that the threads join.
* Introducing a way of marking types as "unsafe to leak", thereby allowing us to continue using the RAII-style API, but preventing use of the guard within reference counted pointers (which can leak).
It's fairly non-trivial to achieve this unsafety, but even the slightest risk is not acceptable for safe functions in the standard library, so we aren't going to ship it as is.
Fortunately, there are a few ways we can adjust things so that the interaction between reference counting and scoped threads doesn't cause problems, e.g. modify the reference counted types so that they cannot store types that require that the destructor be run like the `scoped` token, or guarantee safety in a way that doesn't hinge on the destructor of an object the user has ownership of.
Rust is in direct competition to C++ and aims to be able to replace it completely. Therefore, Rust needs the direct comparison to C++ to show how it's better.
It's unfortunate that this feature won't make into 1.0. It was one of the more exciting concurrency features that looked like it would be in 1.0 until this bug.
See Steve's last example here. http://blog.rust-lang.org/2015/04/10/Fearless-Concurrency.ht...
Personally speaking, and looking others threads on /r/rust, there is a fair amount of frustration when certain things don't work expected due to borrow checker (lifetimes, lexical scoping).
So when people who try Rust get a fair amount of smugness about safety when working with it... they will upvote stories where safety has been proved unsound in Rust.