diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 229fcd2b429cf..fe2f25a396557 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -389,8 +389,12 @@ struct ArcInner { strong: Atomic, // the value usize::MAX acts as a sentinel for temporarily "locking" the - // ability to upgrade weak pointers or downgrade strong ones; this is used - // to avoid races in `make_mut` and `get_mut`. + // weak count, preventing `Arc::downgrade` from racing to create new + // `Weak` references. `Arc::is_unique` (which backs `Arc::get_mut`) + // needs to observe both the strong and weak counts as indicating + // uniqueness in one logical atomic step; since they live in separate + // atomic words, it locks the weak count while reading the strong + // count to keep the two reads consistent. weak: Atomic, data: T,