File tree 1 file changed +14
-0
lines changed
1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,21 @@ use crate::fmt;
76
76
/// destroyed, but not all platforms have this guard. Those platforms that do
77
77
/// not guard typically have a synthetic limit after which point no more
78
78
/// 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.
79
82
///
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
80
94
/// [`with`]: LocalKey::with
81
95
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
82
96
pub struct LocalKey < T : ' static > {
You can’t perform that action at this time.
0 commit comments