File tree Expand file tree Collapse file tree 7 files changed +15
-21
lines changed Expand file tree Collapse file tree 7 files changed +15
-21
lines changed Original file line number Diff line number Diff line change @@ -29,9 +29,8 @@ impl<T: Send + Sync + 'static> Lazy<T> {
2929 /// Safety: `init` must not call `get` on the variable that is being
3030 /// initialized.
3131 pub const unsafe fn new ( init : fn ( ) -> Arc < T > ) -> Lazy < T > {
32- // `lock` is never initialized fully, so this mutex is reentrant!
33- // Do not use it in a way that might be reentrant, that could lead to
34- // aliasing `&mut`.
32+ // `lock` is never initialized fully, so it is UB to attempt to
33+ // acquire this mutex reentrantly!
3534 Lazy {
3635 lock : Mutex :: new ( ) ,
3736 ptr : Cell :: new ( ptr:: null_mut ( ) ) ,
Original file line number Diff line number Diff line change @@ -80,9 +80,8 @@ mod imp {
8080
8181 static mut ARGC : isize = 0 ;
8282 static mut ARGV : * const * const u8 = ptr:: null ( ) ;
83- // `ENV_LOCK` is never initialized fully, so this mutex is reentrant!
84- // Do not use it in a way that might be reentrant, that could lead to
85- // aliasing `&mut`.
83+ // `ENV_LOCK` is never initialized fully, so it is UB to attempt to
84+ // acquire this mutex reentrantly!
8685 static LOCK : Mutex = Mutex :: new ( ) ;
8786
8887 pub unsafe fn init ( argc : isize , argv : * const * const u8 ) {
Original file line number Diff line number Diff line change @@ -33,9 +33,8 @@ use sys::fd;
3333use vec;
3434
3535const TMPBUF_SZ : usize = 128 ;
36- // `ENV_LOCK` is never initialized fully, so this mutex is reentrant!
37- // Do not use it in a way that might be reentrant, that could lead to
38- // aliasing `&mut`.
36+ // `ENV_LOCK` is never initialized fully, so it is UB to attempt to
37+ // acquire this mutex reentrantly!
3938static ENV_LOCK : Mutex = Mutex :: new ( ) ;
4039
4140
Original file line number Diff line number Diff line change @@ -23,9 +23,8 @@ type Queue = Vec<Box<dyn FnBox()>>;
2323// on poisoning and this module needs to operate at a lower level than requiring
2424// the thread infrastructure to be in place (useful on the borders of
2525// initialization/destruction).
26- // `LOCK` is never initialized fully, so this mutex is reentrant!
27- // Do not use it in a way that might be reentrant, that could lead to
28- // aliasing `&mut`.
26+ // `LOCK` is never initialized fully, so it is UB to attempt to
27+ // acquire this mutex reentrantly!
2928static LOCK : Mutex = Mutex :: new ( ) ;
3029static mut QUEUE : * mut Queue = ptr:: null_mut ( ) ;
3130
Original file line number Diff line number Diff line change @@ -24,9 +24,9 @@ impl Mutex {
2424 ///
2525 /// Behavior is undefined if the mutex is moved after it is
2626 /// first used with any of the functions below.
27- /// Also, the mutex might not be fully functional without calling
28- /// `init`! For example, on unix, the mutex is reentrant
29- /// until `init` reconfigures it appropriately .
27+ /// Also, until `init` is called, behavior is undefined if this
28+ /// mutex is ever used reentrantly, i.e., `raw_lock` or `try_lock`
29+ /// are called by the thread currently holding the lock .
3030 pub const fn new ( ) -> Mutex { Mutex ( imp:: Mutex :: new ( ) ) }
3131
3232 /// Prepare the mutex for use.
Original file line number Diff line number Diff line change @@ -161,9 +161,8 @@ impl StaticKey {
161161 // Additionally a 0-index of a tls key hasn't been seen on windows, so
162162 // we just simplify the whole branch.
163163 if imp:: requires_synchronized_create ( ) {
164- // `INIT_LOCK` is never initialized fully, so this mutex is reentrant!
165- // Do not use it in a way that might be reentrant, that could lead to
166- // aliasing `&mut`.
164+ // `INIT_LOCK` is never initialized fully, so it is UB to attempt to
165+ // acquire this mutex reentrantly!
167166 static INIT_LOCK : Mutex = Mutex :: new ( ) ;
168167 let _guard = INIT_LOCK . lock ( ) ;
169168 let mut key = self . key . load ( Ordering :: SeqCst ) ;
Original file line number Diff line number Diff line change @@ -940,9 +940,8 @@ pub struct ThreadId(u64);
940940impl ThreadId {
941941 // Generate a new unique thread ID.
942942 fn new ( ) -> ThreadId {
943- // `GUARD` is never initialized fully, so this mutex is reentrant!
944- // Do not use it in a way that might be reentrant, that could lead to
945- // aliasing `&mut`.
943+ // `GUARD` is never initialized fully, so it is UB to attempt to
944+ // acquire this mutex reentrantly!
946945 static GUARD : mutex:: Mutex = mutex:: Mutex :: new ( ) ;
947946 static mut COUNTER : u64 = 0 ;
948947
You can’t perform that action at this time.
0 commit comments