Bug 1444290 - Forget bg SDR runnable reference when dispatching r?froydnj draft
authorDoug Thayer <dothayer@mozilla.com>
Thu, 22 Mar 2018 09:31:40 -0700
changeset 771160 bb4b95e577582e8951c7e6f0e9f2c1e94512efcf
parent 768133 748f4a1baef345a1db72774393b3e45fcd40a9a1
push id103590
push userbmo:dothayer@mozilla.com
push dateThu, 22 Mar 2018 16:32:20 +0000
reviewersfroydnj
bugs1444290
milestone61.0a1
Bug 1444290 - Forget bg SDR runnable reference when dispatching r?froydnj We're seeing a crash in tests from trying to release the promise in this runnable from the background thread we create to run this method. The only way I can see that happening is that the bg thread loses the race with the main thread to drop its reference to the runnable, causing it to call the destructor. Rather than calling the helper that adds a reference to the runnable and then forgets it, let's just forget it here. MozReview-Commit-ID: LXpC8Kr2SBb
security/manager/ssl/SecretDecoderRing.cpp
--- a/security/manager/ssl/SecretDecoderRing.cpp
+++ b/security/manager/ssl/SecretDecoderRing.cpp
@@ -52,17 +52,17 @@ void BackgroundSdrEncryptStrings(const n
     NS_NewRunnableFunction("BackgroundSdrEncryptStringsResolve",
                            [rv, aPromise = Move(aPromise), cipherTexts = Move(cipherTexts)]() {
                              if (NS_FAILED(rv)) {
                                aPromise->MaybeReject(rv);
                              } else {
                                aPromise->MaybeResolve(cipherTexts);
                              }
                            }));
-  NS_DispatchToMainThread(runnable);
+  NS_DispatchToMainThread(runnable.forget());
 }
 
 nsresult
 SecretDecoderRing::Encrypt(const nsACString& data, /*out*/ nsACString& result)
 {
   UniquePK11SlotInfo slot(PK11_GetInternalKeySlot());
   if (!slot) {
     return NS_ERROR_NOT_AVAILABLE;