The codepaths related to the session setup are currently very error prone, since they use a lot of async code, but don't protect the internal state of the objects sufficiently. This can be solved by moving all async code and the related state to dedicated job objects. In particular are synchronous dialogs invoked, meaning almost arbitrary callbacks can occur if the user forgets a dialog and then closes it, at which point the object may already be in a completely different state. Some examples are: * SessionPrivate::handleSslError invokes a dialog at the end of a process started by SessionPrivate::startSsl, while the process depends on the internal state of SessionThread and startSsl may be invoked multiple times. This means SessoinThread::sslErrorHandlerResponse can be invoked at any time, even if a second run of startSsl already succeeded and already established a secure connection. * SessionPool::onPasswordRequestDone can be invoked again due to a stale password dialog getting completed. At this stage assumptions about the internal state (such as m_pendingInitialSession being set in the ReconnectNeeded) are likely to not be true anymore. The bottom line is, either protect async codepaths from being entered multiple times, or move the state to separate job objects, so the code can safely be run multiple times in parallel. I'm pretty sure this would fix at least some of the crashes we have in the imap resource. Reproducible: Always
This bug has only been reported for versions older than KDEPIM 4.14 (at most akonadi-1.3). Can anyone tell if this bug still present? If noone confirms this bug for a recent version of akonadi (part of KDE Applications 15.08 or later), it gets closed in about three months.
Just as announced in my last comment, I close this bug. If you encounter it again in a recent version (at least 5.0 aka 15.08), please open a new one unless it already exists. Thank you for all your input.