-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
De-stabilize thread::scoped
and friends
#24385
Conversation
Per analysis on crates.io, we do not expect this change to impact much code in practice. Note also that |
Issue rust-lang#24292 demonstrates that the `scoped` API as currently offered can be memory-unsafe: the `JoinGuard` can be moved into a context that will fail to execute destructors prior to the stack frame being popped (for example, by creating an `Rc` cycle). This commit reverts the APIs to `unstable` status while a long-term solution is worked out. (There are several possible ways to address this issue; it's not a fundamental problem with the `scoped` idea, but rather an indication that Rust doesn't currently provide a good way to ensure that destructors are run within a particular stack frame.) [breaking-change]
@bors: r-, going to generalize |
⌛ Testing commit 6399bb4 with merge e627752... |
💔 Test failed - auto-mac-64-opt |
`thread::spawn` was previously restricted to closures that return `()`, which limited the utility of joining on a spawned thread. However, there is no reason for this restriction, and this commit allows arbitrary return types. Since it introduces a type parameter to `JoinHandle`, it's technically a: [breaking-change] However, no code is actually expected to break.
@alexcrichton Now with (Still running |
Orly? This'll break hyper, at least. @reem |
⌛ Testing commit a94040f with merge 05c52dd... |
💔 Test failed - auto-win-32-nopt-t |
@bors: retry On Mon, Apr 13, 2015 at 4:57 PM, bors notifications@github.com wrote:
|
⌛ Testing commit a94040f with merge a492093... |
💔 Test failed - auto-win-32-opt |
@bors: retry On Mon, Apr 13, 2015 at 5:07 PM, bors notifications@github.com wrote:
|
⌛ Testing commit a94040f with merge 9103a0e... |
@bors: r- There are some doc issues, need to rewrite the concurrency chapter. |
💔 Test failed - auto-win-64-nopt-t |
@seanmonstar our use in hyper can be adapted to spawn, but it does cost some additional |
@bors: r=alexcrichton p=100 |
📌 Commit a9fd41e has been approved by |
Given that both of the proposed solutions (unless I'm missing something) change the required bounds of |
Only one of the proposed solutions involves changing these types, and for that approach to work it would need to be backwards-compatible anyway. Essentially, it would introduce a new marker trait that all existing types would satisfy automatically, and that was assumed automatically in most contexts (a bit like However, that's a fairly drastic piece of design, and a much simpler solution is just to not use RAII for fn foo() {
finally(|| {
// code to run now
}, || {
// code to run afterwards, even on a panic
}
} We have some specific ideas about how to make a nice API along these lines work with |
⌛ Testing commit a9fd41e with merge 203fd1c... |
Perhaps I misinterpreted the comment about "like Arena" to mean that it would entail adding a lifetime to The Absent such a solution, the existence of The other reason I think it's worth considering Leak is that I suspect the ability to declare that a destructor really does have to be run (with the usual caveats around abort) is important for other cases than Edit: I don't think (I believe a way to justify building this into the compiler might be to treat |
💔 Test failed - auto-linux-64-opt |
Conflicts: src/libstd/thread/mod.rs src/test/bench/shootout-mandelbrot.rs src/test/bench/shootout-reverse-complement.rs src/test/run-pass/capturing-logging.rs src/test/run-pass/issue-9396.rs src/test/run-pass/tcp-accept-stress.rs src/test/run-pass/tcp-connect-timeouts.rs src/test/run-pass/tempfile.rs
Landed in #24433 |
☔ The latest upstream changes (presumably #24433) made this pull request unmergeable. Please resolve the merge conflicts. |
Issue #24292 demonstrates that the
scoped
API as currently offered canbe memory-unsafe: the
JoinGuard
can be moved into a context that willfail to execute destructors prior to the stack frame being popped (for
example, by creating an
Rc
cycle).This commit reverts the APIs to
unstable
status while a long-termsolution is worked out.
(There are several possible ways to address this issue; it's not a
fundamental problem with the
scoped
idea, but rather an indicationthat Rust doesn't currently provide a good way to ensure that
destructors are run within a particular stack frame.)
r? @alexcrichton