Title: [189783] releases/WebKitGTK/webkit-2.10/Source/WebCore
- Revision
- 189783
- Author
- carlo...@webkit.org
- Date
- 2015-09-15 00:20:22 -0700 (Tue, 15 Sep 2015)
Log Message
Merge r189526 - Crash when WebCore::SQLiteFileSystem::openDatabase is called from multiple threads
https://bugs.webkit.org/show_bug.cgi?id=143245
Reviewed by Darin Adler.
sqlite3_initialize is documented to be thread-safe, and to be called automatically by the
library when needed, so applications should never need to call it directly. The problem is,
it's not thread-safe: we have documented instances of GNOME Builder, Devhelp, Epiphany, and
cinnamon-screensaver crashing when sqlite3_initialize is called simultaneously in separate
threads (usually inside sqlite3_open). So call it manually, guarded using std::call_once, to
make sure that the library is fully initialized before the first call to sqlite3_open. It's
a good idea to do this regardless, because the documentation says it could be required in
a future release of SQLite. (Though the use of std::call_once should not be needed, and is
only used to attempt to work around the crashes.)
This is a workaround for an SQLite bug that might have been fixed upstream, but the SQLite
developers are not really confident in the thread-safety of this function, and have advised
that we carry the workaround. Seems like a good idea.
* platform/sql/SQLiteDatabase.cpp:
(WebCore::SQLiteDatabase::SQLiteDatabase):
Modified Paths
Diff
Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog (189782 => 189783)
--- releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog 2015-09-15 07:17:25 UTC (rev 189782)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog 2015-09-15 07:20:22 UTC (rev 189783)
@@ -1,3 +1,27 @@
+2015-09-08 Michael Catanzaro <mcatanz...@igalia.com>
+
+ Crash when WebCore::SQLiteFileSystem::openDatabase is called from multiple threads
+ https://bugs.webkit.org/show_bug.cgi?id=143245
+
+ Reviewed by Darin Adler.
+
+ sqlite3_initialize is documented to be thread-safe, and to be called automatically by the
+ library when needed, so applications should never need to call it directly. The problem is,
+ it's not thread-safe: we have documented instances of GNOME Builder, Devhelp, Epiphany, and
+ cinnamon-screensaver crashing when sqlite3_initialize is called simultaneously in separate
+ threads (usually inside sqlite3_open). So call it manually, guarded using std::call_once, to
+ make sure that the library is fully initialized before the first call to sqlite3_open. It's
+ a good idea to do this regardless, because the documentation says it could be required in
+ a future release of SQLite. (Though the use of std::call_once should not be needed, and is
+ only used to attempt to work around the crashes.)
+
+ This is a workaround for an SQLite bug that might have been fixed upstream, but the SQLite
+ developers are not really confident in the thread-safety of this function, and have advised
+ that we carry the workaround. Seems like a good idea.
+
+ * platform/sql/SQLiteDatabase.cpp:
+ (WebCore::SQLiteDatabase::SQLiteDatabase):
+
2015-09-08 Chris Dumez <cdu...@apple.com>
document.importNode(node, deep): deep's default value should be false
Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/sql/SQLiteDatabase.cpp (189782 => 189783)
--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/sql/SQLiteDatabase.cpp 2015-09-15 07:17:25 UTC (rev 189782)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/sql/SQLiteDatabase.cpp 2015-09-15 07:20:22 UTC (rev 189783)
@@ -31,6 +31,8 @@
#include "Logging.h"
#include "SQLiteFileSystem.h"
#include "SQLiteStatement.h"
+#include <mutex>
+#include <sqlite3.h>
#include <thread>
#include <wtf/Threading.h>
#include <wtf/text/CString.h>
@@ -57,6 +59,22 @@
, m_openErrorMessage()
, m_lastChangesCount(0)
{
+ static std::once_flag flag;
+ std::call_once(flag, [] {
+ // It should be safe to call this outside of std::call_once, since it is documented to be
+ // completely threadsafe. But in the past it was not safe, and the SQLite developers still
+ // aren't confident that it really is, and we still support ancient versions of SQLite. So
+ // std::call_once is used to stay on the safe side. See bug #143245.
+ int ret = sqlite3_initialize();
+ if (ret != SQLITE_OK) {
+#if SQLITE_VERSION_NUMBER >= 3007015
+ WTFLogAlways("Failed to initialize SQLite: %s", sqlite3_errstr(ret));
+#else
+ WTFLogAlways("Failed to initialize SQLite");
+#endif
+ CRASH();
+ }
+ });
}
SQLiteDatabase::~SQLiteDatabase()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes