Bug 1517071 - Clear AsyncWaitRunnable::mStream when cancelled. r=froydnj
authorAndrew McCreight <continuation@gmail.com>
Fri, 11 Jan 2019 16:57:51 +0000
changeset 453492 e4cbf560928e09c1d7003e5375a5601eabb79c61
parent 453491 49bb9b849c4af957e6f51b16731b98ed0ef72e85
child 453493 9edd4ab366410d8a6b4a3a9c5c47b630bac08e73
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,21 @@ class NonBlockingAsyncInputStream::Async
         mStream(aStream),
         mCallback(aCallback) {}
 
   NS_IMETHOD
   Run() override {
     mStream->RunAsyncWaitCallback(this, mCallback.forget());
     return NS_OK;
   }
+
+  nsresult 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) {}