Skip to content

Commit

Permalink
Disable at_exit handlers
Browse files Browse the repository at this point in the history
The [final step](rust-lang#19654) of
runtime removal changes the threading/process model so that the process
shuts down when the main thread exits. But several shared resources,
like the helper thread for timeouts, are shut down when the main thread
exits (but before the process ends), and they are not prepared to be
used after shut down, but other threads may try to access them during
the shutdown sequence of the main thread.

As an interim solution, the `at_exit` cleanup routine is simply skipped.

Ultimately, these resources should be made to safely handle asynchronous
shutdown, usually by panicking if called from a detached thread when the
main thread is ending.

See issue for details rust-lang#20012

This is a [breaking-change] for anyone relying on `at_exit`.
  • Loading branch information
aturon committed Dec 19, 2014
1 parent a9e7669 commit 903c5a8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/libstd/rt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,8 @@ pub fn at_exit<F:FnOnce()+Send>(f: F) {
pub unsafe fn cleanup() {
args::cleanup();
sys::stack_overflow::cleanup();
at_exit_imp::cleanup();
// FIXME: (#20012): the resources being cleaned up by at_exit
// currently are not prepared for cleanup to happen asynchronously
// with detached threads using the resources; for now, we leak.
// at_exit_imp::cleanup();
}

0 comments on commit 903c5a8

Please sign in to comment.