File tree 7 files changed +15
-21
lines changed
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> {
29
29
/// Safety: `init` must not call `get` on the variable that is being
30
30
/// initialized.
31
31
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!
35
34
Lazy {
36
35
lock : Mutex :: new ( ) ,
37
36
ptr : Cell :: new ( ptr:: null_mut ( ) ) ,
Original file line number Diff line number Diff line change @@ -80,9 +80,8 @@ mod imp {
80
80
81
81
static mut ARGC : isize = 0 ;
82
82
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!
86
85
static LOCK : Mutex = Mutex :: new ( ) ;
87
86
88
87
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;
33
33
use vec;
34
34
35
35
const 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!
39
38
static ENV_LOCK : Mutex = Mutex :: new ( ) ;
40
39
41
40
Original file line number Diff line number Diff line change @@ -23,9 +23,8 @@ type Queue = Vec<Box<dyn FnBox()>>;
23
23
// on poisoning and this module needs to operate at a lower level than requiring
24
24
// the thread infrastructure to be in place (useful on the borders of
25
25
// 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!
29
28
static LOCK : Mutex = Mutex :: new ( ) ;
30
29
static mut QUEUE : * mut Queue = ptr:: null_mut ( ) ;
31
30
Original file line number Diff line number Diff line change @@ -24,9 +24,9 @@ impl Mutex {
24
24
///
25
25
/// Behavior is undefined if the mutex is moved after it is
26
26
/// 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 .
30
30
pub const fn new ( ) -> Mutex { Mutex ( imp:: Mutex :: new ( ) ) }
31
31
32
32
/// Prepare the mutex for use.
Original file line number Diff line number Diff line change @@ -161,9 +161,8 @@ impl StaticKey {
161
161
// Additionally a 0-index of a tls key hasn't been seen on windows, so
162
162
// we just simplify the whole branch.
163
163
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!
167
166
static INIT_LOCK : Mutex = Mutex :: new ( ) ;
168
167
let _guard = INIT_LOCK . lock ( ) ;
169
168
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);
940
940
impl ThreadId {
941
941
// Generate a new unique thread ID.
942
942
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!
946
945
static GUARD : mutex:: Mutex = mutex:: Mutex :: new ( ) ;
947
946
static mut COUNTER : u64 = 0 ;
948
947
You can’t perform that action at this time.
0 commit comments