forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lock the atexit_hooks during execution of the hooks on shutdown.
Fixes JuliaLang#49841. Follow-up to JuliaLang#49774. This PR makes two changes: 1. It locks `atexit_hooks` while iterating the hooks during execution of `_atexit()` at shutdown. - This prevents any data races if another Task is registering a new atexit hook while the hooks are being evaluated. 2. It defines semantics for what happens if another Task attempts to register another atexit hook _after all the hooks have finished_, and we've proceeded on to the rest of shutdown. - Previously, those atexit hooks would be _ignored,_ which violates the user's expectations and violates the "atexit" contract. - Now, the attempt to register the atexit hook will **throw an exception,** which ensures that we never break our promise, since the user was never able to register the atexit hook at all. - This does mean that users will need to handle the thrown exception and likely do now whatever tear down they were hoping to delay until exit.
- Loading branch information
Showing
2 changed files
with
129 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters