Title: [122328] trunk/Source/WebCore
Revision
122328
Author
[email protected]
Date
2012-07-11 06:44:48 -0700 (Wed, 11 Jul 2012)

Log Message

[BlackBerry] crash in CookieDatabaseBackingStore.
https://bugs.webkit.org/show_bug.cgi?id=90270

Reviewed by George Staikos.

There is one case for this crash.
1. A browser crashes and locks cookies' database for a while.
2. Open a new browser when the old one doesn't finish crashing.
3. The new one writes the cookies' database and receives a SQLITE_BUSY error
   in CookieDatabaseBackingStore's invokeOpen. So this database isn't opened.
4. invokeGetCookiesWithLimit returns 0.
5. Crash happens when using a null pointer.

Add function setBusyTimeout(1000) and a guard for cookies' pointer.
setBusyTimeout will call sqlite3_busy_timeout.

When the SQLite database is accessed for reading it is locked for writing
until the reading access is finished. Another process cannot access the database
while it is locked. The timeout time sets a limit while this process tries to access
the locked database. If the database is unlocked within the timeout time it can be
accessed, otherwise an access fails.

No new tests. This crash is hard to reproduce, and it happens only on our platform.

* platform/blackberry/CookieDatabaseBackingStore/CookieDatabaseBackingStore.cpp:
(WebCore::CookieDatabaseBackingStore::getCookiesFromDatabase):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (122327 => 122328)


--- trunk/Source/WebCore/ChangeLog	2012-07-11 12:30:10 UTC (rev 122327)
+++ trunk/Source/WebCore/ChangeLog	2012-07-11 13:44:48 UTC (rev 122328)
@@ -1,3 +1,32 @@
+2012-07-11  Jason Liu  <[email protected]>
+
+        [BlackBerry] crash in CookieDatabaseBackingStore.
+        https://bugs.webkit.org/show_bug.cgi?id=90270
+
+        Reviewed by George Staikos.
+
+        There is one case for this crash.
+        1. A browser crashes and locks cookies' database for a while.
+        2. Open a new browser when the old one doesn't finish crashing.
+        3. The new one writes the cookies' database and receives a SQLITE_BUSY error
+           in CookieDatabaseBackingStore's invokeOpen. So this database isn't opened.
+        4. invokeGetCookiesWithLimit returns 0.
+        5. Crash happens when using a null pointer.
+
+        Add function setBusyTimeout(1000) and a guard for cookies' pointer.
+        setBusyTimeout will call sqlite3_busy_timeout.
+
+        When the SQLite database is accessed for reading it is locked for writing
+        until the reading access is finished. Another process cannot access the database
+        while it is locked. The timeout time sets a limit while this process tries to access
+        the locked database. If the database is unlocked within the timeout time it can be
+        accessed, otherwise an access fails.
+
+        No new tests. This crash is hard to reproduce, and it happens only on our platform.
+
+        * platform/blackberry/CookieDatabaseBackingStore/CookieDatabaseBackingStore.cpp:
+        (WebCore::CookieDatabaseBackingStore::getCookiesFromDatabase):
+
 2012-07-11  Vsevolod Vlasov  <[email protected]>
 
         Web Inspector: Move revisions support to UISourceCode.

Modified: trunk/Source/WebCore/platform/blackberry/CookieDatabaseBackingStore/CookieDatabaseBackingStore.cpp (122327 => 122328)


--- trunk/Source/WebCore/platform/blackberry/CookieDatabaseBackingStore/CookieDatabaseBackingStore.cpp	2012-07-11 12:30:10 UTC (rev 122327)
+++ trunk/Source/WebCore/platform/blackberry/CookieDatabaseBackingStore/CookieDatabaseBackingStore.cpp	2012-07-11 13:44:48 UTC (rev 122328)
@@ -218,6 +218,8 @@
     // This table schema is compliant with Mozilla's.
     createTableQuery += " (" + databaseFields + ", " + primaryKeyFields+");";
 
+    m_db.setBusyTimeout(1000);
+
     if (!m_db.executeCommand(createTableQuery)) {
         LOG_ERROR("Could not create the table to store the cookies into. No cookie will be stored!");
         LOG_ERROR("SQLite Error Message: %s", m_db.lastErrorMsg());
@@ -346,7 +348,8 @@
     TypedReplyBuffer< Vector<ParsedCookie*>* > replyBuffer(0);
     dispatchMessage(createMethodCallMessageWithReturn(&CookieDatabaseBackingStore::invokeGetCookiesWithLimit, &replyBuffer, this, limit));
     Vector<ParsedCookie*>* cookies = replyBuffer.pointer();
-    stackOfCookies.swap(*cookies);
+    if (cookies)
+        stackOfCookies.swap(*cookies);
     delete cookies;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to