about summary refs log tree commit diff
path: root/src/libstd/rt
diff options
context:
space:
mode:
authorAaron Turon <aturon@mozilla.com>2014-12-18 23:29:30 -0800
committerAaron Turon <aturon@mozilla.com>2014-12-18 23:35:53 -0800
commit903c5a8f69714382ec9fc22745f902c3e219cb68 (patch)
treedf8c8b58d6d706b7c51836632bc4c628861ea752 /src/libstd/rt
parenta9e7669cdc551588144a5b56db0b42dd35b71876 (diff)
downloadrust-903c5a8f69714382ec9fc22745f902c3e219cb68.tar.gz
rust-903c5a8f69714382ec9fc22745f902c3e219cb68.zip
Disable at_exit handlers
The [final step](https://github.com/rust-lang/rust/pull/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 https://github.com/rust-lang/rust/issues/20012

This is a [breaking-change] for anyone relying on `at_exit`.
Diffstat (limited to 'src/libstd/rt')
-rw-r--r--src/libstd/rt/mod.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs
index fd50d845716..8d9c1268e7e 100644
--- a/src/libstd/rt/mod.rs
+++ b/src/libstd/rt/mod.rs
@@ -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();
 }