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
--- 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;