Title: [196899] releases/WebKitGTK/webkit-2.10
Revision
196899
Author
[email protected]
Date
2016-02-22 00:14:59 -0800 (Mon, 22 Feb 2016)

Log Message

Merge r195652 - 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: releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog (196898 => 196899)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog	2016-02-22 08:06:38 UTC (rev 196898)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog	2016-02-22 08:14:59 UTC (rev 196899)
@@ -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-25  Eric Carlson  <[email protected]>
 
         Media "ended" event incorrectly fires when currentTime is set

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog (196898 => 196899)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog	2016-02-22 08:06:38 UTC (rev 196898)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog	2016-02-22 08:14:59 UTC (rev 196899)
@@ -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  Konstantin Tokarev  <[email protected]>
 
         Do not convert GlyphBufferAdvance to FloatSize

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/Modules/webdatabase/DatabaseThread.cpp (196898 => 196899)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/Modules/webdatabase/DatabaseThread.cpp	2016-02-22 08:06:38 UTC (rev 196898)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/Modules/webdatabase/DatabaseThread.cpp	2016-02-22 08:14:59 UTC (rev 196899)
@@ -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: releases/WebKitGTK/webkit-2.10/Source/WebCore/Modules/webdatabase/DatabaseThread.h (196898 => 196899)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/Modules/webdatabase/DatabaseThread.h	2016-02-22 08:06:38 UTC (rev 196898)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/Modules/webdatabase/DatabaseThread.h	2016-02-22 08:14:59 UTC (rev 196899)
@@ -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