AccountState: Attempt to fix a crash
authorOlivier Goffart <ogoffart@woboq.com>
Tue, 28 Mar 2017 13:11:58 +0000 (15:11 +0200)
committerMarkus Goetz <markus@woboq.com>
Tue, 28 Mar 2017 16:04:19 +0000 (18:04 +0200)
Backtrace from the crash reporter:

Crash: EXCEPTION_ACCESS_VIOLATION_READ at 0x21
  File "qcoreapplication.cpp", line 1281, in QCoreApplication::postEvent
  File "qobject.cpp", line 2125, in QObject::deleteLater
  File "connectionvalidator.cpp", line 240, in OCC::ConnectionValidator::reportResult
  File "connectionvalidator.cpp", line 206, in OCC::ConnectionValidator::slotAuthFailed
  File "moc_connectionvalidator.cpp", line 127, in OCC::ConnectionValidator::qt_static_metacall
  File "qobject.cpp", line 3716, in QMetaObject::activate
  File "moc_networkjobs.cpp", line 653, in OCC::PropfindJob::finishedWithError
  File "networkjobs.cpp", line 570, in OCC::PropfindJob::finished

I believe the problem is caused because 'this' was deleted in ConnectionValidator::reportResult
as the signal connectionResult gets emited. The AccountState::slotConnectionValidatorResult
slot does indeed call slotInvalidCredentials which might call {Shibboleth,Http}Credentials::fetchFromKeychain
which might emit fetched directly, which will call AccountState::slotCredentialsFetched
which deletes the _connectionValidator

So use deleteLater when deleting the _connectionValidator, hoping this helps

src/gui/accountstate.cpp

index 38bae16a93d1bed468e963f460684a05720ddf09..fb2dc5360fed02980a6aa17b3918f0f897aa4640 100644 (file)
@@ -281,9 +281,12 @@ void AccountState::slotCredentialsFetched(AbstractCredentials* credentials)
 
     _waitingForNewCredentials = false;
 
-    // When new credentials become available we always want to restart the
-    // connection validation, even if it's currently running.
-    delete _connectionValidator;
+    if (_connectionValidator) {
+        // When new credentials become available we always want to restart the
+        // connection validation, even if it's currently running.
+        _connectionValidator->deleteLater();
+        _connectionValidator = 0;
+    }
 
     checkConnectivity();
 }
@@ -298,9 +301,12 @@ void AccountState::slotCredentialsAsked(AbstractCredentials* credentials)
         return;
     }
 
-    // When new credentials become available we always want to restart the
-    // connection validation, even if it's currently running.
-    delete _connectionValidator;
+    if (_connectionValidator) {
+        // When new credentials become available we always want to restart the
+        // connection validation, even if it's currently running.
+        _connectionValidator->deleteLater();
+        _connectionValidator = 0;
+    }
 
     checkConnectivity();
 }