diff options
| author | Ralf Jung <post@ralfj.de> | 2018-08-08 18:12:33 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2018-08-08 18:12:33 +0200 |
| commit | 31bec788f46c73ab14c72868dc6141141320a058 (patch) | |
| tree | f51b52ff63cf9160f406ff019aabcec034b056e4 /src/libstd/sys_common | |
| parent | 645388583ca47357a6a2e5878a9cde84e2e579d3 (diff) | |
| download | rust-31bec788f46c73ab14c72868dc6141141320a058.tar.gz rust-31bec788f46c73ab14c72868dc6141141320a058.zip | |
avoid using the word 'initialized' to talk about that non-reentrant-capable state of the mutex
Diffstat (limited to 'src/libstd/sys_common')
| -rw-r--r-- | src/libstd/sys_common/at_exit_imp.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys_common/mutex.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sys_common/thread_local.rs | 2 |
3 files changed, 5 insertions, 3 deletions
diff --git a/src/libstd/sys_common/at_exit_imp.rs b/src/libstd/sys_common/at_exit_imp.rs index 85679837312..76e5df2c865 100644 --- a/src/libstd/sys_common/at_exit_imp.rs +++ b/src/libstd/sys_common/at_exit_imp.rs @@ -23,7 +23,7 @@ type Queue = Vec<Box<dyn FnBox()>>; // on poisoning and this module needs to operate at a lower level than requiring // the thread infrastructure to be in place (useful on the borders of // initialization/destruction). -// `LOCK` is never initialized fully, so it is UB to attempt to +// We never call `LOCK.init()`, so it is UB to attempt to // acquire this mutex reentrantly! static LOCK: Mutex = Mutex::new(); static mut QUEUE: *mut Queue = ptr::null_mut(); diff --git a/src/libstd/sys_common/mutex.rs b/src/libstd/sys_common/mutex.rs index 74e1defd9f4..c6d531c7a1a 100644 --- a/src/libstd/sys_common/mutex.rs +++ b/src/libstd/sys_common/mutex.rs @@ -32,7 +32,9 @@ impl Mutex { /// Prepare the mutex for use. /// /// This should be called once the mutex is at a stable memory address. - /// Behavior is undefined unless this is called before any other operation. + /// If called, this must be the very first thing that happens to the mutex. + /// Calling it in parallel with or after any operation (including another + /// `init()`) is undefined behavior. #[inline] pub unsafe fn init(&mut self) { self.0.init() } diff --git a/src/libstd/sys_common/thread_local.rs b/src/libstd/sys_common/thread_local.rs index 9db7d732698..bb72cb0930a 100644 --- a/src/libstd/sys_common/thread_local.rs +++ b/src/libstd/sys_common/thread_local.rs @@ -161,7 +161,7 @@ impl StaticKey { // Additionally a 0-index of a tls key hasn't been seen on windows, so // we just simplify the whole branch. if imp::requires_synchronized_create() { - // `INIT_LOCK` is never initialized fully, so it is UB to attempt to + // We never call `INIT_LOCK.init()`, so it is UB to attempt to // acquire this mutex reentrantly! static INIT_LOCK: Mutex = Mutex::new(); let _guard = INIT_LOCK.lock(); |
