Fix leak of ModuleInformations in BBQPlan constructors.
authorkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Jun 2017 00:32:25 +0000 (00:32 +0000)
committerkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Jun 2017 00:32:25 +0000 (00:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173577

Reviewed by Saam Barati.

This patch fixes a leak in the BBQPlan constructiors. Previously,
the plans were calling makeRef on the newly constructed objects.
This patch fixes the issue and uses adoptRef instead. Additionally,
an old, incorrect, attempt to fix the leak is removed.

* inspector/remote/cocoa/RemoteInspectorXPCConnection.mm:
(Inspector::RemoteInspectorXPCConnection::RemoteInspectorXPCConnection):
* jit/JITWorklist.cpp:
(JSC::JITWorklist::Thread::Thread):
* runtime/PromiseDeferredTimer.cpp:
(JSC::PromiseDeferredTimer::addPendingPromise):
* runtime/VM.cpp:
(JSC::VM::VM):
* wasm/WasmBBQPlan.cpp:
(JSC::Wasm::BBQPlan::BBQPlan):
* wasm/WasmPlan.cpp:
(JSC::Wasm::Plan::Plan):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218619 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/PromiseDeferredTimer.cpp
Source/JavaScriptCore/wasm/WasmBBQPlan.cpp
Source/JavaScriptCore/wasm/WasmPlan.cpp

index 534c3be..d968b6d 100644 (file)
@@ -1,3 +1,28 @@
+2017-06-20  Keith Miller  <keith_miller@apple.com>
+
+        Fix leak of ModuleInformations in BBQPlan constructors.
+        https://bugs.webkit.org/show_bug.cgi?id=173577
+
+        Reviewed by Saam Barati.
+
+        This patch fixes a leak in the BBQPlan constructiors. Previously,
+        the plans were calling makeRef on the newly constructed objects.
+        This patch fixes the issue and uses adoptRef instead. Additionally,
+        an old, incorrect, attempt to fix the leak is removed.
+
+        * inspector/remote/cocoa/RemoteInspectorXPCConnection.mm:
+        (Inspector::RemoteInspectorXPCConnection::RemoteInspectorXPCConnection):
+        * jit/JITWorklist.cpp:
+        (JSC::JITWorklist::Thread::Thread):
+        * runtime/PromiseDeferredTimer.cpp:
+        (JSC::PromiseDeferredTimer::addPendingPromise):
+        * runtime/VM.cpp:
+        (JSC::VM::VM):
+        * wasm/WasmBBQPlan.cpp:
+        (JSC::Wasm::BBQPlan::BBQPlan):
+        * wasm/WasmPlan.cpp:
+        (JSC::Wasm::Plan::Plan):
+
 2017-06-20  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: Send context attributes for tracked canvases
index ba50087..3dcaeaa 100644 (file)
@@ -109,10 +109,8 @@ void PromiseDeferredTimer::addPendingPromise(JSPromiseDeferred* ticket, Vector<S
         dependencies.append(Strong<JSCell>(*m_vm, ticket));
         result.iterator->value = WTFMove(dependencies);
     } else {
-        // We need to make sure we move dependencies into a non-reference type so we actually destruct it.
-        Vector<Strong<JSCell>> deps = WTFMove(dependencies);
         dataLogLnIf(verbose, "Adding new dependencies for promise: ", RawPointer(ticket));
-        result.iterator->value.appendVector(deps);
+        result.iterator->value.appendVector(dependencies);
     }
 
 #ifndef NDEBUG
index c13b766..b3b3198 100644 (file)
@@ -59,7 +59,7 @@ BBQPlan::BBQPlan(VM* vm, Ref<ModuleInformation> info, AsyncWork work, Completion
 }
 
 BBQPlan::BBQPlan(VM* vm, Vector<uint8_t>&& source, AsyncWork work, CompletionTask&& task)
-    : BBQPlan(vm, makeRef(*new ModuleInformation(WTFMove(source))), work, WTFMove(task))
+    : BBQPlan(vm, adoptRef(*new ModuleInformation(WTFMove(source))), work, WTFMove(task))
 {
     m_state = State::Initial;
 }
index 7b238f8..0202fa2 100644 (file)
@@ -59,7 +59,7 @@ Plan::Plan(VM* vm, Ref<ModuleInformation> info, CompletionTask&& task)
 }
 
 Plan::Plan(VM* vm, const uint8_t* source, size_t sourceLength, CompletionTask&& task)
-    : m_moduleInformation(makeRef(*new ModuleInformation(Vector<uint8_t>())))
+    : m_moduleInformation(adoptRef(*new ModuleInformation(Vector<uint8_t>())))
     , m_source(source)
     , m_sourceLength(sourceLength)
 {