[Content Extensions] Don't unmap shared memory while using it.
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Apr 2015 17:54:22 +0000 (17:54 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Apr 2015 17:54:22 +0000 (17:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=143625

Reviewed by Darin Adler.

* Shared/WebCompiledContentExtension.cpp:
(WebKit::WebCompiledContentExtension::createFromCompiledContentExtensionData):
* Shared/WebCompiledContentExtensionData.h:
(WebKit::WebCompiledContentExtensionData::WebCompiledContentExtensionData):
* UIProcess/API/APIUserContentExtensionStore.cpp:
(API::createExtension):
Keep the Data object alive as long as the SharedMemory that uses it.

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

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebCompiledContentExtension.cpp
Source/WebKit2/Shared/WebCompiledContentExtensionData.h
Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.cpp

index 5b11927..9bde50d 100644 (file)
@@ -1,3 +1,18 @@
+2015-04-10  Alex Christensen  <achristensen@webkit.org>
+
+        [Content Extensions] Don't unmap shared memory while using it.
+        https://bugs.webkit.org/show_bug.cgi?id=143625
+
+        Reviewed by Darin Adler.
+
+        * Shared/WebCompiledContentExtension.cpp:
+        (WebKit::WebCompiledContentExtension::createFromCompiledContentExtensionData):
+        * Shared/WebCompiledContentExtensionData.h:
+        (WebKit::WebCompiledContentExtensionData::WebCompiledContentExtensionData):
+        * UIProcess/API/APIUserContentExtensionStore.cpp:
+        (API::createExtension):
+        Keep the Data object alive as long as the SharedMemory that uses it.
+
 2015-04-12  Darin Adler  <darin@apple.com>
 
         [Cocoa] Localizable strings are inconsistent and need to be regenerated
index 8047fef..49eb7cd 100644 (file)
@@ -52,12 +52,8 @@ Ref<WebCompiledContentExtension> WebCompiledContentExtension::createFromCompiled
     memcpy(static_cast<char*>(sharedMemory->data()), compilerData.actions.data(), compilerData.actions.size());
     memcpy(static_cast<char*>(sharedMemory->data()) + compilerData.actions.size(), compilerData.bytecode.data(), compilerData.bytecode.size());
 
-    WebCompiledContentExtensionData data;
-    data.data = WTF::move(sharedMemory);
-    data.actionsOffset = 0;
-    data.actionsSize = compilerData.actions.size();
-    data.bytecodeOffset = compilerData.actions.size();
-    data.bytecodeSize = compilerData.bytecode.size();
+    NetworkCache::Data fileData; // We don't have an mmap'd file to keep alive here, so just use an empty Data object.
+    WebCompiledContentExtensionData data(WTF::move(sharedMemory), fileData, 0, compilerData.actions.size(), compilerData.actions.size(), compilerData.bytecode.size());
 
     return create(WTF::move(data));
 }
index 266b3f4..40085a3 100644 (file)
@@ -28,6 +28,7 @@
 
 #if ENABLE(CONTENT_EXTENSIONS)
 
+#include "NetworkCacheData.h"
 #include "SharedMemory.h"
 #include <wtf/RefPtr.h>
 
@@ -44,8 +45,9 @@ public:
     {
     }
     
-    WebCompiledContentExtensionData(RefPtr<SharedMemory> data, unsigned actionsOffset, unsigned actionsSize, unsigned bytecodeOffset, unsigned bytecodeSize)
-        : data(data)
+    WebCompiledContentExtensionData(RefPtr<SharedMemory>&& data, NetworkCache::Data fileData, unsigned actionsOffset, unsigned actionsSize, unsigned bytecodeOffset, unsigned bytecodeSize)
+        : data(WTF::move(data))
+        , fileData(fileData)
         , actionsOffset(actionsOffset)
         , actionsSize(actionsSize)
         , bytecodeOffset(bytecodeOffset)
@@ -57,6 +59,7 @@ public:
     static bool decode(IPC::ArgumentDecoder&, WebCompiledContentExtensionData&);
 
     RefPtr<SharedMemory> data;
+    NetworkCache::Data fileData;
     unsigned actionsOffset { 0 };
     unsigned actionsSize { 0 };
     unsigned bytecodeOffset { 0 };
index 6cac419..28d9377 100644 (file)
@@ -235,7 +235,8 @@ static RefPtr<API::UserContentExtension> createExtension(const String& identifie
 {
     auto sharedMemory = WebKit::SharedMemory::createFromVMBuffer(const_cast<uint8_t*>(fileData.data()), fileData.size());
     auto compiledContentExtensionData = WebKit::WebCompiledContentExtensionData(
-        sharedMemory,
+        WTF::move(sharedMemory),
+        fileData,
         metaData.actionsOffset,
         metaData.actionsSize,
         metaData.bytecodeOffset,