Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve at_exit strategy after std::thread lands #20012

Closed
aturon opened this issue Dec 19, 2014 · 2 comments · Fixed by #20045 or #23267
Closed

Resolve at_exit strategy after std::thread lands #20012

aturon opened this issue Dec 19, 2014 · 2 comments · Fixed by #20045 or #23267
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows P-medium Medium priority

Comments

@aturon
Copy link
Member

aturon commented Dec 19, 2014

The final step 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.

@aturon aturon added A-libs A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows labels Dec 19, 2014
@aturon
Copy link
Member Author

aturon commented Dec 19, 2014

cc @alexcrichton

Nominating for P-High.

aturon added a commit to aturon/rust that referenced this issue Dec 19, 2014
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`.
alexcrichton added a commit to alexcrichton/rust that referenced this issue Dec 30, 2014
The new semantics of this function are that the callbacks are run when the *main
thread* exits, not when all threads have exited. This implies that other threads
may still be running when the `at_exit` callbacks are invoked and users need to
be prepared for this situation.

Users in the standard library have been audited in accordance to these new rules
as well.

Closes rust-lang#20012
alexcrichton added a commit to alexcrichton/rust that referenced this issue Dec 31, 2014
The new semantics of this function are that the callbacks are run when the *main
thread* exits, not when all threads have exited. This implies that other threads
may still be running when the `at_exit` callbacks are invoked and users need to
be prepared for this situation.

Users in the standard library have been audited in accordance to these new rules
as well.

Closes rust-lang#20012
@alexcrichton
Copy link
Member

Fix was reverted, not actually closed.

@alexcrichton alexcrichton reopened this Dec 31, 2014
@brson brson added the P-medium Medium priority label Jan 15, 2015
Manishearth added a commit to Manishearth/rust that referenced this issue Mar 11, 2015
 This reverts commit aec67c2.

Closes rust-lang#20012

This is temporarily rebased on rust-lang#23245 as it would otherwise conflict, the last commit is the only one relevant to this PR though.
bors added a commit that referenced this issue Mar 13, 2015
This reverts commit aec67c2.

Closes #20012

This is temporarily rebased on #23245 as it would otherwise conflict, the last commit is the only one relevant to this PR though.
bors added a commit that referenced this issue Mar 20, 2015
This reverts commit aec67c2.

Closes #20012

This is temporarily rebased on #23245 as it would otherwise conflict, the last commit is the only one relevant to this PR though.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows P-medium Medium priority
Projects
None yet
3 participants