Title: [231812] trunk
Revision
231812
Author
beid...@apple.com
Date
2018-05-15 12:07:13 -0700 (Tue, 15 May 2018)

Log Message

Fix crash after a Worker terminates but there are still IDB transactions the server is trying to open for it.
<rdar://problem/33744241> and https://bugs.webkit.org/show_bug.cgi?id=185653

Reviewed by Andy Estes.

Source/WebCore:

Test: storage/indexeddb/modern/worker-transaction-open-after-worker-stop.html

* Modules/indexeddb/client/IDBConnectionProxy.cpp:
(WebCore::IDBClient::IDBConnectionProxy::didStartTransaction): It's okay to not be able to find a pending TX
  that the server has started. e.g. When it was a WebWorker that asked for the TX but it has since terminated.

LayoutTests:

* storage/indexeddb/modern/resources/worker-transaction-open-after-worker-stop.js: Added.
(const.errorHandler):
(openRequest.onupgradeneeded):
(tx.oncomplete):
(openRequest.onsuccess):
(deleteRequest.onerror.deleteRequest.onblocked.deleteRequest.onsuccess):
* storage/indexeddb/modern/worker-transaction-open-after-worker-stop-expected.txt: Added.
* storage/indexeddb/modern/worker-transaction-open-after-worker-stop.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (231811 => 231812)


--- trunk/LayoutTests/ChangeLog	2018-05-15 19:04:22 UTC (rev 231811)
+++ trunk/LayoutTests/ChangeLog	2018-05-15 19:07:13 UTC (rev 231812)
@@ -1,3 +1,19 @@
+2018-05-15  Brady Eidson  <beid...@apple.com>
+
+        Fix crash after a Worker terminates but there are still IDB transactions the server is trying to open for it.
+        <rdar://problem/33744241> and https://bugs.webkit.org/show_bug.cgi?id=185653
+
+        Reviewed by Andy Estes.
+
+        * storage/indexeddb/modern/resources/worker-transaction-open-after-worker-stop.js: Added.
+        (const.errorHandler):
+        (openRequest.onupgradeneeded):
+        (tx.oncomplete):
+        (openRequest.onsuccess):
+        (deleteRequest.onerror.deleteRequest.onblocked.deleteRequest.onsuccess):
+        * storage/indexeddb/modern/worker-transaction-open-after-worker-stop-expected.txt: Added.
+        * storage/indexeddb/modern/worker-transaction-open-after-worker-stop.html: Added.
+
 2018-05-15  Ryan Haddad  <ryanhad...@apple.com>
 
         Unreviewed, rolling out r231763.

Added: trunk/LayoutTests/storage/indexeddb/modern/resources/worker-transaction-open-after-worker-stop.js (0 => 231812)


--- trunk/LayoutTests/storage/indexeddb/modern/resources/worker-transaction-open-after-worker-stop.js	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/resources/worker-transaction-open-after-worker-stop.js	2018-05-15 19:07:13 UTC (rev 231812)
@@ -0,0 +1,35 @@
+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 hasMessagedBack = false;
+
+        // Queue up many transactions. 
+        // We'll kill the worker from the main thread after the first transaction completes,
+        // meaning there will be many more that would trigger the crash after the worker is gone.
+        for (var i = 0; i < 1000; ++i) {
+            var tx = db.transaction('test', 'readwrite');
+            tx._onerror_ = errorHandler;
+            tx._onabort_ = errorHandler;
+            tx._oncomplete_ = function () {
+                console.log('All done!');
+                if (!hasMessagedBack) {
+                    hasMessagedBack = true;
+                    postMessage('First transaction completed');
+                }
+            };
+        }
+    };
+};

Added: trunk/LayoutTests/storage/indexeddb/modern/worker-transaction-open-after-worker-stop-expected.txt (0 => 231812)


--- trunk/LayoutTests/storage/indexeddb/modern/worker-transaction-open-after-worker-stop-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/worker-transaction-open-after-worker-stop-expected.txt	2018-05-15 19:07:13 UTC (rev 231812)
@@ -0,0 +1 @@
+If this test completes without crashing, it passed.

Added: trunk/LayoutTests/storage/indexeddb/modern/worker-transaction-open-after-worker-stop.html (0 => 231812)


--- trunk/LayoutTests/storage/indexeddb/modern/worker-transaction-open-after-worker-stop.html	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/worker-transaction-open-after-worker-stop.html	2018-05-15 19:07:13 UTC (rev 231812)
@@ -0,0 +1,25 @@
+<script type="text/_javascript_">
+if (testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+function finishTest()
+{	
+    if (testRunner)
+        testRunner.notifyDone();
+}
+
+var w = new Worker('resources/worker-transaction-open-after-worker-stop.js');
+w._onmessage_ = function() {
+	w.terminate();
+	
+	// Queue up an "open" that will necessarily queue up behind the many 
+	// transactions that the Worker queued up.
+    indexedDB.open('test')._onsuccess_ = function (event) {
+		finishTest();
+    };
+}
+
+</script>
+If this test completes without crashing, it passed.

Modified: trunk/Source/WebCore/ChangeLog (231811 => 231812)


--- trunk/Source/WebCore/ChangeLog	2018-05-15 19:04:22 UTC (rev 231811)
+++ trunk/Source/WebCore/ChangeLog	2018-05-15 19:07:13 UTC (rev 231812)
@@ -1,3 +1,16 @@
+2018-05-15  Brady Eidson  <beid...@apple.com>
+
+        Fix crash after a Worker terminates but there are still IDB transactions the server is trying to open for it.
+        <rdar://problem/33744241> and https://bugs.webkit.org/show_bug.cgi?id=185653
+
+        Reviewed by Andy Estes.
+
+        Test: storage/indexeddb/modern/worker-transaction-open-after-worker-stop.html
+
+        * Modules/indexeddb/client/IDBConnectionProxy.cpp:
+        (WebCore::IDBClient::IDBConnectionProxy::didStartTransaction): It's okay to not be able to find a pending TX
+          that the server has started. e.g. When it was a WebWorker that asked for the TX but it has since terminated.
+
 2018-05-15  Thomas Klausner  <t...@giga.or.at>
 
         Add missing header to fix build.

Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp (231811 => 231812)


--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp	2018-05-15 19:04:22 UTC (rev 231811)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp	2018-05-15 19:07:13 UTC (rev 231812)
@@ -316,7 +316,8 @@
         transaction = m_pendingTransactions.take(transactionIdentifier);
     }
 
-    ASSERT(transaction);
+    if (!transaction)
+        return;
 
     transaction->performCallbackOnOriginThread(*transaction, &IDBTransaction::didStart, error);
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to