Bug 1517071 - Clear AsyncWaitRunnable::mStream when cancelled. r=froydnj
☠☠ backed out by 5c5b31c72808 ☠ ☠
authorAndrew McCreight <continuation@gmail.com>
Fri, 11 Jan 2019 14:36:45 +0000
changeset 453486 3b7589bf68d0033774d061fbd7b03c50984046d9
parent 453485 69cb7d6acb86156d05e9032cfde384b731bd796b
child 453487 5c5b31c72808fc1ef6a0d7b1ac8c4481222d56ba
push id35357
push usernerli@mozilla.com
push dateFri, 11 Jan 2019 21:54:07 +0000
treeherdermozilla-central@0ce024c91511 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1517071
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1517071 - Clear AsyncWaitRunnable::mStream when cancelled. r=froydnj AsyncWaitRunnable holds a strong reference to its stream, and NonBlockingAsyncInputStream holds a strong reference to the runnable. The cycle gets broken in the RunAsyncWaitCallback() method of the stream, but if the runnable is cancelled then we leak them both. This patch fixes that by clearing the pointer to the stream when the runnable is cancelled, breaking the cycle. Differential Revision: https://phabricator.services.mozilla.com/D16248
testing/web-platform/meta/FileAPI/FileReader/__dir__.ini
xpcom/io/NonBlockingAsyncInputStream.cpp
deleted file mode 100644
--- a/testing/web-platform/meta/FileAPI/FileReader/__dir__.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-lsan-allowed: [Alloc, AllocateProtoAndIfaceCache, EntrySlotOrCreate, MakeNotNull, MakeUnique, Malloc, NS_NewCStringInputStream, NewEmptyScopeData, NewPage, ProtoAndIfaceCache, js_new, js_pod_calloc, js_pod_malloc, js_pod_realloc, mozilla::BackgroundHangThread::ReportHang, mozilla::NonBlockingAsyncInputStream::AsyncWait, mozilla::NonBlockingAsyncInputStream::Create, mozilla::dom::Blob::Constructor, mozilla::dom::Blob::Create, mozilla::dom::FileReader::Constructor, mozilla::dom::StringBlobImpl::Create, mozilla::dom::WorkerPrivate::GetOrCreateGlobalScope, mozilla::dom::WorkerPrivate::WorkerPrivate, mozilla::dom::WorkerThread::Create, nsThread::nsThread]
-leak-threshold: [default:51200]
--- a/xpcom/io/NonBlockingAsyncInputStream.cpp
+++ b/xpcom/io/NonBlockingAsyncInputStream.cpp
@@ -24,16 +24,22 @@ class NonBlockingAsyncInputStream::Async
         mStream(aStream),
         mCallback(aCallback) {}
 
   NS_IMETHOD
   Run() override {
     mStream->RunAsyncWaitCallback(this, mCallback.forget());
     return NS_OK;
   }
+
+  NS_IMETHOD
+  Cancel() override {
+    mStream = nullptr;
+    return NS_OK;
+  }
 };
 
 NS_IMPL_ADDREF(NonBlockingAsyncInputStream);
 NS_IMPL_RELEASE(NonBlockingAsyncInputStream);
 
 NonBlockingAsyncInputStream::WaitClosureOnly::WaitClosureOnly(
     AsyncWaitRunnable* aRunnable, nsIEventTarget* aEventTarget)
     : mRunnable(aRunnable), mEventTarget(aEventTarget) {}