Title: [195652] trunk
Revision
195652
Author
[email protected]
Date
2016-01-26 19:45:09 -0800 (Tue, 26 Jan 2016)

Log Message

fast/history/page-cache-webdatabase-no-transaction-db.html flakily crashes
https://bugs.webkit.org/show_bug.cgi?id=153525

Reviewed by Andreas Kling.

Source/WebCore:

The test was crashing because DatabaseThread::hasPendingDatabaseActivity()
was accessing m_openDatabaseSet from the main thread without any locking
mechanism. This is an issue because m_openDatabaseSet is altered by the
database thread.

No new tests, already covered by fast/history/page-cache-webdatabase-no-transaction-db.html.

* Modules/webdatabase/DatabaseThread.cpp:
(WebCore::DatabaseThread::databaseThread):
(WebCore::DatabaseThread::recordDatabaseOpen):
(WebCore::DatabaseThread::recordDatabaseClosed):
(WebCore::DatabaseThread::hasPendingDatabaseActivity):
* Modules/webdatabase/DatabaseThread.h:

LayoutTests:

Unskip fast/history/page-cache-webdatabase-no-transaction-db.html now
that it no longer crashes.

* TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (195651 => 195652)


--- trunk/LayoutTests/ChangeLog	2016-01-27 03:16:06 UTC (rev 195651)
+++ trunk/LayoutTests/ChangeLog	2016-01-27 03:45:09 UTC (rev 195652)
@@ -1,3 +1,15 @@
+2016-01-26  Chris Dumez  <[email protected]>
+
+        fast/history/page-cache-webdatabase-no-transaction-db.html flakily crashes
+        https://bugs.webkit.org/show_bug.cgi?id=153525
+
+        Reviewed by Andreas Kling.
+
+        Unskip fast/history/page-cache-webdatabase-no-transaction-db.html now
+        that it no longer crashes.
+
+        * TestExpectations:
+
 2016-01-26  Brady Eidson  <[email protected]>
 
         Modern IDB: Key generator support for SQLite backend.

Modified: trunk/LayoutTests/TestExpectations (195651 => 195652)


--- trunk/LayoutTests/TestExpectations	2016-01-27 03:16:06 UTC (rev 195651)
+++ trunk/LayoutTests/TestExpectations	2016-01-27 03:45:09 UTC (rev 195652)
@@ -848,9 +848,6 @@
 http/tests/security/contentSecurityPolicy/1.1/scripthash-default-src.html # Needs expected file.
 http/tests/security/contentSecurityPolicy/1.1/stylehash-default-src.html # Needs expected file.
 
-# This test flakily crashes, skip it until the crash is fixed.
-webkit.org/b/153525 fast/history/page-cache-webdatabase-no-transaction-db.html [ Skip ]
-
 # These state object tests purposefully stress a resource limit, and take multiple seconds to run.
 loader/stateobjects/pushstate-size-iframe.html [ Slow ]
 loader/stateobjects/pushstate-size.html [ Slow ]

Modified: trunk/Source/WebCore/ChangeLog (195651 => 195652)


--- trunk/Source/WebCore/ChangeLog	2016-01-27 03:16:06 UTC (rev 195651)
+++ trunk/Source/WebCore/ChangeLog	2016-01-27 03:45:09 UTC (rev 195652)
@@ -1,3 +1,24 @@
+2016-01-26  Chris Dumez  <[email protected]>
+
+        fast/history/page-cache-webdatabase-no-transaction-db.html flakily crashes
+        https://bugs.webkit.org/show_bug.cgi?id=153525
+
+        Reviewed by Andreas Kling.
+
+        The test was crashing because DatabaseThread::hasPendingDatabaseActivity()
+        was accessing m_openDatabaseSet from the main thread without any locking
+        mechanism. This is an issue because m_openDatabaseSet is altered by the
+        database thread.
+
+        No new tests, already covered by fast/history/page-cache-webdatabase-no-transaction-db.html.
+
+        * Modules/webdatabase/DatabaseThread.cpp:
+        (WebCore::DatabaseThread::databaseThread):
+        (WebCore::DatabaseThread::recordDatabaseOpen):
+        (WebCore::DatabaseThread::recordDatabaseClosed):
+        (WebCore::DatabaseThread::hasPendingDatabaseActivity):
+        * Modules/webdatabase/DatabaseThread.h:
+
 2016-01-26  Joseph Pecoraro  <[email protected]>
 
         Unreviewed CMake build fix after r195644.

Modified: trunk/Source/WebCore/Modules/webdatabase/DatabaseThread.cpp (195651 => 195652)


--- trunk/Source/WebCore/Modules/webdatabase/DatabaseThread.cpp	2016-01-27 03:16:06 UTC (rev 195651)
+++ trunk/Source/WebCore/Modules/webdatabase/DatabaseThread.cpp	2016-01-27 03:45:09 UTC (rev 195652)
@@ -117,14 +117,18 @@
 
     // Close the databases that we ran transactions on. This ensures that if any transactions are still open, they are rolled back and we don't leave the database in an
     // inconsistent or locked state.
-    if (m_openDatabaseSet.size() > 0) {
-        // As the call to close will modify the original set, we must take a copy to iterate over.
-        DatabaseSet openSetCopy;
-        openSetCopy.swap(m_openDatabaseSet);
-        for (auto& openDatabase : openSetCopy)
-            openDatabase->close();
+    DatabaseSet openSetCopy;
+    {
+        LockHolder lock(m_openDatabaseSetMutex);
+        if (m_openDatabaseSet.size() > 0) {
+            // As the call to close will modify the original set, we must take a copy to iterate over.
+            openSetCopy.swap(m_openDatabaseSet);
+        }
     }
 
+    for (auto& openDatabase : openSetCopy)
+        openDatabase->close();
+
     // Detach the thread so its resources are no longer of any concern to anyone else
     detachThread(m_threadID);
 
@@ -139,6 +143,8 @@
 
 void DatabaseThread::recordDatabaseOpen(Database* database)
 {
+    LockHolder lock(m_openDatabaseSetMutex);
+
     ASSERT(currentThread() == m_threadID);
     ASSERT(database);
     ASSERT(!m_openDatabaseSet.contains(database));
@@ -147,6 +153,8 @@
 
 void DatabaseThread::recordDatabaseClosed(Database* database)
 {
+    LockHolder lock(m_openDatabaseSetMutex);
+
     ASSERT(currentThread() == m_threadID);
     ASSERT(database);
     ASSERT(m_queue.killed() || m_openDatabaseSet.contains(database));
@@ -183,6 +191,7 @@
 
 bool DatabaseThread::hasPendingDatabaseActivity() const
 {
+    LockHolder lock(m_openDatabaseSetMutex);
     for (auto& database : m_openDatabaseSet) {
         if (database->hasPendingCreationEvent() || database->hasPendingTransaction())
             return true;

Modified: trunk/Source/WebCore/Modules/webdatabase/DatabaseThread.h (195651 => 195652)


--- trunk/Source/WebCore/Modules/webdatabase/DatabaseThread.h	2016-01-27 03:16:06 UTC (rev 195651)
+++ trunk/Source/WebCore/Modules/webdatabase/DatabaseThread.h	2016-01-27 03:45:09 UTC (rev 195652)
@@ -80,6 +80,7 @@
 
     // This set keeps track of the open databases that have been used on this thread.
     typedef HashSet<RefPtr<Database>> DatabaseSet;
+    mutable Lock m_openDatabaseSetMutex;
     DatabaseSet m_openDatabaseSet;
 
     std::unique_ptr<SQLTransactionClient> m_transactionClient;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to