Bug 1517071 - Clear AsyncWaitRunnable::mStream when cancelled. r=froydnj, a=RyanVM
authorAndrew McCreight <continuation@gmail.com>
Fri, 11 Jan 2019 16:57:51 +0000
changeset 506661 5b52f9f8300439f6f58beead39f28ee22faf4863
parent 506660 d566c5f82f8b4d53ed05bc8836ea0b9d7dee051c
child 506662 7bfd0ddce88e35eb5be95af2f62d7a50208b0741
push id10501
push userryanvm@gmail.com
push dateSat, 12 Jan 2019 21:41:05 +0000
treeherdermozilla-beta@5b52f9f83004 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj, RyanVM
bugs1517071
milestone65.0
Bug 1517071 - Clear AsyncWaitRunnable::mStream when cancelled. r=froydnj, a=RyanVM 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) {}