about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-07-06 06:48:12 +0000
committerbors <bors@rust-lang.org>2018-07-06 06:48:12 +0000
commit4d9fa2326e184314749ccf79203f5ecc35e6225c (patch)
treecb6e15283a2ed07d3b8f63bd5ef6147a0a4d1f2c /src/liballoc
parenta8403e1cda2e0cba4f2c7282ab5adb5392bef473 (diff)
parente6ddbabb5998d1a83918831f3859a95a2adb110c (diff)
downloadrust-4d9fa2326e184314749ccf79203f5ecc35e6225c.tar.gz
rust-4d9fa2326e184314749ccf79203f5ecc35e6225c.zip
Auto merge of #52088 - kennytm:rollup, r=kennytm
Rollup of 14 pull requests

Successful merges:

 - #51619 (rust: add initial changes to support powerpc64le musl)
 - #51793 (Fix variant background color on hover in search results)
 - #52005 (Update LLVM to bring in a wasm codegen fix)
 - #52016 (Deduplicate error reports for statics)
 - #52019 ([cross-lang-lto] Allow the linker to choose the LTO-plugin (which is useful when using LLD))
 - #52030 (Any docs preposition change)
 - #52031 (Strenghten synchronization in `Arc::is_unique`)
 - #52033 ([Gardening] Update outdated comments: ByVal -> Scalar)
 - #52055 (Include VS 2017 in error message.)
 - #52063 (Add a link to the rustc docs)
 - #52073 (Add a punch card to weird expressions test)
 - #52080 (Improve dependency deduplication diagnostics)
 - #52093 (rustc: Update tracking issue for wasm_import_module)
 - #52096 (Fix typo in cell.rs)

Failed merges:
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/sync.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs
index 2abd9c85c57..4244b09b18f 100644
--- a/src/liballoc/sync.rs
+++ b/src/liballoc/sync.rs
@@ -886,13 +886,14 @@ impl<T: ?Sized> Arc<T> {
         // holder.
         //
         // The acquire label here ensures a happens-before relationship with any
-        // writes to `strong` prior to decrements of the `weak` count (via drop,
-        // which uses Release).
+        // writes to `strong` (in particular in `Weak::upgrade`) prior to decrements
+        // of the `weak` count (via `Weak::drop`, which uses release).  If the upgraded
+        // weak ref was never dropped, the CAS here will fail so we do not care to synchronize.
         if self.inner().weak.compare_exchange(1, usize::MAX, Acquire, Relaxed).is_ok() {
-            // Due to the previous acquire read, this will observe any writes to
-            // `strong` that were due to upgrading weak pointers; only strong
-            // clones remain, which require that the strong count is > 1 anyway.
-            let unique = self.inner().strong.load(Relaxed) == 1;
+            // This needs to be an `Acquire` to synchronize with the decrement of the `strong`
+            // counter in `drop` -- the only access that happens when any but the last reference
+            // is being dropped.
+            let unique = self.inner().strong.load(Acquire) == 1;
 
             // The release write here synchronizes with a read in `downgrade`,
             // effectively preventing the above read of `strong` from happening