<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[218573] releases/WebKitGTK/webkit-2.16</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/218573">218573</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2017-06-20 01:59:44 -0700 (Tue, 20 Jun 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/218041">r218041</a> - Crash when IndexedDB's getAll is used inside a Web Worker.
https://bugs.webkit.org/show_bug.cgi?id=172434

Reviewed by Andy Estes.

Source/WebCore:

Test: storage/indexeddb/modern/worker-getall.html

* Modules/indexeddb/IDBGetAllResult.cpp:
(WebCore::IDBGetAllResult::IDBGetAllResult): Add an isolated-copying constructor.
(WebCore::IDBGetAllResult::isolatedCopy):
* Modules/indexeddb/IDBGetAllResult.h:

* Modules/indexeddb/shared/IDBResultData.cpp:
(WebCore::IDBResultData::isolatedCopy): Actually copy the IDBGetAllResult.

LayoutTests:

* storage/indexeddb/modern/resources/worker-getall.js: Added.
* storage/indexeddb/modern/worker-getall-expected.txt: Added.
* storage/indexeddb/modern/worker-getall.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit216LayoutTestsChangeLog">releases/WebKitGTK/webkit-2.16/LayoutTests/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit216SourceWebCoreChangeLog">releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit216SourceWebCoreModulesindexeddbIDBGetAllResultcpp">releases/WebKitGTK/webkit-2.16/Source/WebCore/Modules/indexeddb/IDBGetAllResult.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit216SourceWebCoreModulesindexeddbIDBGetAllResulth">releases/WebKitGTK/webkit-2.16/Source/WebCore/Modules/indexeddb/IDBGetAllResult.h</a></li>
<li><a href="#releasesWebKitGTKwebkit216SourceWebCoreModulesindexeddbsharedIDBResultDatacpp">releases/WebKitGTK/webkit-2.16/Source/WebCore/Modules/indexeddb/shared/IDBResultData.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit216LayoutTestsstorageindexeddbmodernresourcesworkergetalljs">releases/WebKitGTK/webkit-2.16/LayoutTests/storage/indexeddb/modern/resources/worker-getall.js</a></li>
<li><a href="#releasesWebKitGTKwebkit216LayoutTestsstorageindexeddbmodernworkergetallexpectedtxt">releases/WebKitGTK/webkit-2.16/LayoutTests/storage/indexeddb/modern/worker-getall-expected.txt</a></li>
<li><a href="#releasesWebKitGTKwebkit216LayoutTestsstorageindexeddbmodernworkergetallhtml">releases/WebKitGTK/webkit-2.16/LayoutTests/storage/indexeddb/modern/worker-getall.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit216LayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.16/LayoutTests/ChangeLog (218572 => 218573)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/LayoutTests/ChangeLog     2017-06-20 08:52:13 UTC (rev 218572)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/ChangeLog        2017-06-20 08:59:44 UTC (rev 218573)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-06-09  Brady Eidson  <beidson@apple.com>
+
+        Crash when IndexedDB's getAll is used inside a Web Worker.
+        https://bugs.webkit.org/show_bug.cgi?id=172434
+
+        Reviewed by Andy Estes.
+
+        * storage/indexeddb/modern/resources/worker-getall.js: Added.
+        * storage/indexeddb/modern/worker-getall-expected.txt: Added.
+        * storage/indexeddb/modern/worker-getall.html: Added.
+
</ins><span class="cx"> 2017-06-08  Ryosuke Niwa  <rniwa@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         Crash inside InsertNodeBeforeCommand via InsertParagraphSeparatorCommand
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit216LayoutTestsstorageindexeddbmodernresourcesworkergetalljs"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.16/LayoutTests/storage/indexeddb/modern/resources/worker-getall.js (0 => 218573)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/LayoutTests/storage/indexeddb/modern/resources/worker-getall.js                           (rev 0)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/storage/indexeddb/modern/resources/worker-getall.js      2017-06-20 08:59:44 UTC (rev 218573)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+const errorHandler = function (event) {
+  console.error(event.target.error);
+}
+
+console.log('Deleting database...');
+var deleteRequest = indexedDB.deleteDatabase('test');
+deleteRequest.onerror = deleteRequest.onblocked = deleteRequest.onsuccess = function () {
+    console.log('Opening database...');
+    var openRequest = indexedDB.open('test');
+    openRequest.onerror = errorHandler;
+    openRequest.onupgradeneeded = function () {
+        var db = openRequest.result;
+        db.createObjectStore('test', {keyPath: 'a'});
+    }
+    openRequest.onsuccess = function (event) {
+        var db = event.target.result;
+
+        var tx = db.transaction('test', 'readwrite');
+        tx.onerror = errorHandler;
+        tx.onabort = errorHandler;
+        tx.oncomplete = function () {
+            console.log('All done!');
+                       postMessage('All done!');
+        };
+
+        var getAllRequest = tx.objectStore('test').getAll();
+        getAllRequest.onerror = errorHandler;
+        getAllRequest.onsuccess = function () {
+            console.log('Success!');
+        };
+    };
+};
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit216LayoutTestsstorageindexeddbmodernworkergetallexpectedtxt"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.16/LayoutTests/storage/indexeddb/modern/worker-getall-expected.txt (0 => 218573)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/LayoutTests/storage/indexeddb/modern/worker-getall-expected.txt                           (rev 0)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/storage/indexeddb/modern/worker-getall-expected.txt      2017-06-20 08:59:44 UTC (rev 218573)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+If this test completes without crashing, it passed.
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit216LayoutTestsstorageindexeddbmodernworkergetallhtml"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.16/LayoutTests/storage/indexeddb/modern/worker-getall.html (0 => 218573)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/LayoutTests/storage/indexeddb/modern/worker-getall.html                           (rev 0)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/storage/indexeddb/modern/worker-getall.html      2017-06-20 08:59:44 UTC (rev 218573)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+<script type="text/javascript">
+if (testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+var w = new Worker('resources/worker-getall.js');
+w.onmessage = function() {
+    if (testRunner)
+        testRunner.notifyDone();
+}
+
+</script>
+If this test completes without crashing, it passed.
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit216SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog (218572 => 218573)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog  2017-06-20 08:52:13 UTC (rev 218572)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog     2017-06-20 08:59:44 UTC (rev 218573)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2017-06-09  Brady Eidson  <beidson@apple.com>
+
+        Crash when IndexedDB's getAll is used inside a Web Worker.
+        https://bugs.webkit.org/show_bug.cgi?id=172434
+
+        Reviewed by Andy Estes.
+
+        Test: storage/indexeddb/modern/worker-getall.html
+
+        * Modules/indexeddb/IDBGetAllResult.cpp:
+        (WebCore::IDBGetAllResult::IDBGetAllResult): Add an isolated-copying constructor.
+        (WebCore::IDBGetAllResult::isolatedCopy):
+        * Modules/indexeddb/IDBGetAllResult.h:
+        
+        * Modules/indexeddb/shared/IDBResultData.cpp:
+        (WebCore::IDBResultData::isolatedCopy): Actually copy the IDBGetAllResult.
+
</ins><span class="cx"> 2017-06-08  Ryosuke Niwa  <rniwa@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         Crash inside InsertNodeBeforeCommand via InsertParagraphSeparatorCommand
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit216SourceWebCoreModulesindexeddbIDBGetAllResultcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/Modules/indexeddb/IDBGetAllResult.cpp (218572 => 218573)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/Source/WebCore/Modules/indexeddb/IDBGetAllResult.cpp      2017-06-20 08:52:13 UTC (rev 218572)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/Modules/indexeddb/IDBGetAllResult.cpp 2017-06-20 08:59:44 UTC (rev 218573)
</span><span class="lines">@@ -42,24 +42,31 @@
</span><span class="cx">         targetVector.uncheckedAppend(element.isolatedCopy());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+IDBGetAllResult::IDBGetAllResult(const IDBGetAllResult& that, IsolatedCopyTag)
+{
+    isolatedCopy(that, *this);
+}
+
</ins><span class="cx"> IDBGetAllResult IDBGetAllResult::isolatedCopy() const
</span><span class="cx"> {
</span><del>-    IDBGetAllResult result;
-    result.m_type = m_type;
</del><ins>+    return { *this, IsolatedCopy };
+}
</ins><span class="cx"> 
</span><del>-    if (WTF::holds_alternative<std::nullptr_t>(m_results))
-        return result;
</del><ins>+void IDBGetAllResult::isolatedCopy(const IDBGetAllResult& source, IDBGetAllResult& destination)
+{
+    destination.m_type = source.m_type;
</ins><span class="cx"> 
</span><del>-    switch (m_type) {
</del><ins>+    if (WTF::holds_alternative<std::nullptr_t>(source.m_results))
+        return;
+
+    switch (source.m_type) {
</ins><span class="cx">     case IndexedDB::GetAllType::Keys:
</span><del>-        isolatedCopyOfVariant<IDBKeyData>(m_results, result.m_results);
</del><ins>+        isolatedCopyOfVariant<IDBKeyData>(source.m_results, destination.m_results);
</ins><span class="cx">         break;
</span><span class="cx">     case IndexedDB::GetAllType::Values:
</span><del>-        isolatedCopyOfVariant<IDBValue>(m_results, result.m_results);
</del><ins>+        isolatedCopyOfVariant<IDBValue>(source.m_results, destination.m_results);
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><del>-
-    return result;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void IDBGetAllResult::addKey(IDBKeyData&& key)
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit216SourceWebCoreModulesindexeddbIDBGetAllResulth"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/Modules/indexeddb/IDBGetAllResult.h (218572 => 218573)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/Source/WebCore/Modules/indexeddb/IDBGetAllResult.h        2017-06-20 08:52:13 UTC (rev 218572)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/Modules/indexeddb/IDBGetAllResult.h   2017-06-20 08:59:44 UTC (rev 218573)
</span><span class="lines">@@ -54,6 +54,8 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    enum IsolatedCopyTag { IsolatedCopy };
+    IDBGetAllResult(const IDBGetAllResult&, IsolatedCopyTag);
</ins><span class="cx">     IDBGetAllResult isolatedCopy() const;
</span><span class="cx"> 
</span><span class="cx">     IndexedDB::GetAllType type() const { return m_type; }
</span><span class="lines">@@ -69,6 +71,8 @@
</span><span class="cx">     WEBCORE_EXPORT Vector<String> allBlobFilePaths() const;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><ins>+    static void isolatedCopy(const IDBGetAllResult& source, IDBGetAllResult& destination);
+
</ins><span class="cx">     IndexedDB::GetAllType m_type { IndexedDB::GetAllType::Keys };
</span><span class="cx">     WTF::Variant<Vector<IDBKeyData>, Vector<IDBValue>, std::nullptr_t> m_results { nullptr };
</span><span class="cx"> };
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit216SourceWebCoreModulesindexeddbsharedIDBResultDatacpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/Modules/indexeddb/shared/IDBResultData.cpp (218572 => 218573)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/Source/WebCore/Modules/indexeddb/shared/IDBResultData.cpp 2017-06-20 08:52:13 UTC (rev 218572)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/Modules/indexeddb/shared/IDBResultData.cpp    2017-06-20 08:59:44 UTC (rev 218573)
</span><span class="lines">@@ -94,6 +94,8 @@
</span><span class="cx">         destination.m_resultKey = std::make_unique<IDBKeyData>(*source.m_resultKey, IDBKeyData::IsolatedCopy);
</span><span class="cx">     if (source.m_getResult)
</span><span class="cx">         destination.m_getResult = std::make_unique<IDBGetResult>(*source.m_getResult, IDBGetResult::IsolatedCopy);
</span><ins>+    if (source.m_getAllResult)
+        destination.m_getAllResult = std::make_unique<IDBGetAllResult>(*source.m_getAllResult, IDBGetAllResult::IsolatedCopy);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> IDBResultData IDBResultData::error(const IDBResourceIdentifier& requestIdentifier, const IDBError& error)
</span></span></pre>
</div>
</div>

</body>
</html>