From 1d9d64ec3cf78dfdddc2239df0d33b08dc442104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Vr=C3=A1til?= Date: Sat, 22 Apr 2023 11:43:02 +0200 Subject: [PATCH] Fix crash on server shutdown When AkonadiServer::quit() is called it clears the vector of existing connections and destroys them. This can race with a resource disconnecting or crashing on its own, which then enqueues a singal emission from the Connection to remove itself from the connections vector as well. Previously the code assumed the Connection must always exist in the vector which caused a crash when it did not...surprise surprise. BUG: 462692 FIXED-IN: 23.04.0 --- src/server/akonadi.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/server/akonadi.cpp b/src/server/akonadi.cpp index 7ede9e238..5ff4a9c46 100644 --- a/src/server/akonadi.cpp +++ b/src/server/akonadi.cpp @@ -230,8 +230,10 @@ void AkonadiServer::connectionDisconnected() auto it = std::find_if(mConnections.begin(), mConnections.end(), [this](const auto &ptr) { return ptr.get() == sender(); }); - Q_ASSERT(it != mConnections.end()); - mConnections.erase(it); + + if (it != mConnections.end()) { + mConnections.erase(it); + } } bool AkonadiServer::setupDatabase() -- 2.40.0