Bug 728653 - Crash in mozilla::storage::Connection::stepStatement @ sqlite3_extended_result_codes. r=mak.
authorRafael Ávila de Espíndola <respindola@mozilla.com>
Thu, 01 Mar 2012 08:13:45 -0500
changeset 88085 b92e7499019ef5d97fd483ca84d45d7e6d2485a0
parent 88084 f50254fe891267904b58c4a38e95ad765fafc78c
child 88086 91ca0cc06f46dc519ee50403131b7f8fd3e4089d
push id22171
push usermak77@bonardo.net
push dateFri, 02 Mar 2012 13:56:30 +0000
treeherdermozilla-central@343ec916dfd5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs728653
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 728653 - Crash in mozilla::storage::Connection::stepStatement @ sqlite3_extended_result_codes. r=mak.
storage/src/mozStorageConnection.cpp
--- a/storage/src/mozStorageConnection.cpp
+++ b/storage/src/mozStorageConnection.cpp
@@ -872,16 +872,26 @@ Connection::getFilename()
 }
 
 int
 Connection::stepStatement(sqlite3_stmt *aStatement)
 {
   bool checkedMainThread = false;
   TimeStamp startTime = TimeStamp::Now();
 
+  // mDBConn may be null if the executing statement has been created and cached
+  // after a call to asyncClose() but before the connection has been nullified
+  // by internalClose().  In such a case closing the connection fails due to
+  // the existence of prepared statements, but mDBConn is set to null
+  // regardless. This usually happens when other tasks using cached statements
+  // are asynchronously scheduled for execution and any of them ends up after
+  // asyncClose. See bug 728653 for details.
+  if (!mDBConn)
+    return SQLITE_MISUSE;
+
   (void)::sqlite3_extended_result_codes(mDBConn, 1);
 
   int srv;
   while ((srv = ::sqlite3_step(aStatement)) == SQLITE_LOCKED_SHAREDCACHE) {
     if (!checkedMainThread) {
       checkedMainThread = true;
       if (::NS_IsMainThread()) {
         NS_WARNING("We won't allow blocking on the main thread!");