/// Safety: `init` must not call `get` on the variable that is being
/// initialized.
pub const unsafe fn new(init: fn() -> Arc<T>) -> Lazy<T> {
- // `lock` is never initialized fully, so this mutex is reentrant!
- // Do not use it in a way that might be reentrant, that could lead to
- // aliasing `&mut`.
+ // `lock` is never initialized fully, so it is UB to attempt to
+ // acquire this mutex reentrantly!
Lazy {
lock: Mutex::new(),
ptr: Cell::new(ptr::null_mut()),
static mut ARGC: isize = 0;
static mut ARGV: *const *const u8 = ptr::null();
- // `ENV_LOCK` is never initialized fully, so this mutex is reentrant!
- // Do not use it in a way that might be reentrant, that could lead to
- // aliasing `&mut`.
+ // `ENV_LOCK` is never initialized fully, so it is UB to attempt to
+ // acquire this mutex reentrantly!
static LOCK: Mutex = Mutex::new();
pub unsafe fn init(argc: isize, argv: *const *const u8) {
use vec;
const TMPBUF_SZ: usize = 128;
-// `ENV_LOCK` is never initialized fully, so this mutex is reentrant!
-// Do not use it in a way that might be reentrant, that could lead to
-// aliasing `&mut`.
+// `ENV_LOCK` is never initialized fully, so it is UB to attempt to
+// acquire this mutex reentrantly!
static ENV_LOCK: Mutex = Mutex::new();
// 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 this mutex is reentrant!
-// Do not use it in a way that might be reentrant, that could lead to
-// aliasing `&mut`.
+// `LOCK` is never initialized fully, so it is UB to attempt to
+// acquire this mutex reentrantly!
static LOCK: Mutex = Mutex::new();
static mut QUEUE: *mut Queue = ptr::null_mut();
///
/// Behavior is undefined if the mutex is moved after it is
/// first used with any of the functions below.
- /// Also, the mutex might not be fully functional without calling
- /// `init`! For example, on unix, the mutex is reentrant
- /// until `init` reconfigures it appropriately.
+ /// Also, until `init` is called, behavior is undefined if this
+ /// mutex is ever used reentrantly, i.e., `raw_lock` or `try_lock`
+ /// are called by the thread currently holding the lock.
pub const fn new() -> Mutex { Mutex(imp::Mutex::new()) }
/// Prepare the mutex for use.
// 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 this mutex is reentrant!
- // Do not use it in a way that might be reentrant, that could lead to
- // aliasing `&mut`.
+ // `INIT_LOCK` is never initialized fully, so it is UB to attempt to
+ // acquire this mutex reentrantly!
static INIT_LOCK: Mutex = Mutex::new();
let _guard = INIT_LOCK.lock();
let mut key = self.key.load(Ordering::SeqCst);
impl ThreadId {
// Generate a new unique thread ID.
fn new() -> ThreadId {
- // `GUARD` is never initialized fully, so this mutex is reentrant!
- // Do not use it in a way that might be reentrant, that could lead to
- // aliasing `&mut`.
+ // `GUARD` is never initialized fully, so it is UB to attempt to
+ // acquire this mutex reentrantly!
static GUARD: mutex::Mutex = mutex::Mutex::new();
static mut COUNTER: u64 = 0;