Skip to content

Commit 903c5a8

Browse files
committed
Disable at_exit handlers
The [final step](#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 #20012 This is a [breaking-change] for anyone relying on `at_exit`.
1 parent a9e7669 commit 903c5a8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libstd/rt/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,5 +162,8 @@ pub fn at_exit<F:FnOnce()+Send>(f: F) {
162162
pub unsafe fn cleanup() {
163163
args::cleanup();
164164
sys::stack_overflow::cleanup();
165-
at_exit_imp::cleanup();
165+
// FIXME: (#20012): the resources being cleaned up by at_exit
166+
// currently are not prepared for cleanup to happen asynchronously
167+
// with detached threads using the resources; for now, we leak.
168+
// at_exit_imp::cleanup();
166169
}

0 commit comments

Comments
 (0)