File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,21 @@ use crate::fmt;
7676/// destroyed, but not all platforms have this guard. Those platforms that do
7777/// not guard typically have a synthetic limit after which point no more
7878/// destructors are run.
79+ /// 3. When the process exits on Windows systems, TLS destructors may only be
80+ /// run on the thread that causes the process to exit. This is because the
81+ /// other threads may be forcibly terminated.
7982///
83+ /// ## Synchronization in thread-local destructors
84+ ///
85+ /// On Windows, synchronization operations (such as [`JoinHandle::join`]) in
86+ /// thread local destructors are prone to deadlocks and so should be avoided.
87+ /// This is because the [loader lock] is held while a destructor is run. The
88+ /// lock is acquired whenever a thread starts or exits or when a DLL is loaded
89+ /// or unloaded. Therefore these events are blocked for as long as a thread
90+ /// local destructor is running.
91+ ///
92+ /// [loader lock]: https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-best-practices
93+ /// [`JoinHandle::join`]: crate::thread::JoinHandle::join
8094/// [`with`]: LocalKey::with
8195#[ stable( feature = "rust1" , since = "1.0.0" ) ]
8296pub struct LocalKey < T : ' static > {
You can’t perform that action at this time.
0 commit comments