Commit 103ab0be authored by Igor Kushnir's avatar Igor Kushnir

Kill CTestFindJob when its project is destroyed

When a user closes a project while its associated CTestFindJob is still
working, the job is not notified and keeps running. After that, when
BackgroundParser eventually parses all documents requested by the job,
the job calls TestController::addTestSuite(). Inside this call the
CTestSuite::project() pointer is dereferenced in
TestView::addTestSuite() => TestView::itemForProject(), which causes a
segmentation fault.

Ideally all associated CTestFindJob-s should be killed just before or
just after a project is closed to revert their no longer useful requests
to BackgroundParser as soon as possible. However, reliably detecting
that the project is no longer open is not straightforward, especially if
the project opening is aborted or the project is closed even before a
CTestFindJob is created. My implementation of such a proper fix is
intertwined with several other CTest-, TestController- and
TestView-related fixes. The combined fix will be so large that it won't
fit into the 5.6 branch. So this commit implements a simple temporary
workaround for the fairly easy to trigger crash: check if the project is
destroyed in CTestFindJob::updateReady() and kill the job if this is the

BUG: 329246
FIXED-IN: 5.6.1
parent ae9f45ae
Pipeline #36695 canceled with stage
......@@ -88,6 +88,13 @@ void CTestFindJob::updateReady(const KDevelop::IndexedString& document, const KD
if (Q_UNLIKELY(!m_suite->project())) {
qCDebug(CMAKE) << "Cannot add test suite" << m_suite->name()
<< "because its project is already destroyed (probably closed by the user).";
qCDebug(CMAKE) << "context update ready" << m_pendingFiles << document.str();
m_suite->loadDeclarations(document, context);
......@@ -24,6 +24,7 @@
#include <language/duchain/indexeddeclaration.h>
#include <util/path.h>
#include <QHash>
#include <QPointer>
namespace KDevelop {
class ReferencedTopDUContext;
......@@ -60,7 +61,7 @@ private:
QStringList m_cases;
QStringList m_args;
QList<KDevelop::Path> m_files;
KDevelop::IProject* m_project;
QPointer<KDevelop::IProject> m_project;
QHash<QString, KDevelop::IndexedDeclaration> m_declarations;
QHash<QString, QString> m_properties;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment