Bug 1397052 - Don't update |result| after the acquire fence in nsThreadSafeRefCnt::operator--. r=froydnj
☠☠ backed out by 6169c1d97aab ☠ ☠
authorBobby Holley <bobbyholley@gmail.com>
Wed, 06 Sep 2017 10:57:19 -0700
changeset 660364 80e9cd4126b49eedcbd9310407997ec429bdc769
parent 660363 fe6a8ed3e4078a3364b1c1318d7ccb797d7d8bdd
child 660365 5f3d4bed0b45019f04aa44e2d353c2d22987185c
push id78390
push userbmo:emilio@crisal.io
push dateWed, 06 Sep 2017 23:04:15 +0000
reviewersfroydnj
bugs1397052
milestone57.0a1
Bug 1397052 - Don't update |result| after the acquire fence in nsThreadSafeRefCnt::operator--. r=froydnj MozReview-Commit-ID: 1Yp4kFXA5gV
xpcom/base/nsISupportsImpl.h
--- a/xpcom/base/nsISupportsImpl.h
+++ b/xpcom/base/nsISupportsImpl.h
@@ -352,17 +352,17 @@ public:
     // to the thread that destroys the object when it reads mValue with
     // acquire semantics.
     nsrefcnt result = mValue.fetch_sub(1, std::memory_order_release) - 1;
     if (result == 0) {
       // We're going to destroy the object on this thread, so we need
       // acquire semantics to synchronize with the memory released by
       // the last release on other threads, that is, to ensure that
       // writes prior to that release are now visible on this thread.
-      result = mValue.load(std::memory_order_acquire);
+      std::atomic_thread_fence(std::memory_order_acquire);
     }
     return result;
   }
 
   MOZ_ALWAYS_INLINE nsrefcnt operator=(nsrefcnt aValue)
   {
     // Use release semantics since we're not sure what the caller is
     // doing.