Bug 330697

Summary: KDevelop crashes when trying to parse CMake project with targets that depends on each other
Product: [Applications] kdevelop Reporter: Oleksandr Senkovych <bjsenya>
Component: Build tools: CMakeAssignee: kdevelop-bugs-null
Status: RESOLVED WORKSFORME    
Severity: crash CC: aleixpol, amantia, kfunk, savoiu, vayerx
Priority: HI Keywords: regression, release_blocker
Version: git master   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: New crash information added by DrKonqi

Description Oleksandr Senkovych 2014-02-03 11:43:35 UTC
If you for some reason create CMake project that has two targets and each one of them has other in dependencies, KDevelop crashes because of tons of recursive procesDependencies calls. 

An example CMakeLists.txt file that crashes KDevelop:

cmake_minimum_required(VERSION 2.8)
add_library(lib1 STATIC file1.cpp)
add_library(lib2 STATIC file2.cpp)
target_link_libraries(lib2 lib1)
target_link_libraries(lib1 lib2)
Comment 1 Kevin Funk 2014-02-03 13:35:57 UTC
Andras had the same problem. That needs to be fixed before release.
Comment 2 Milian Wolff 2014-02-04 15:46:20 UTC
*** Bug 330755 has been marked as a duplicate of this bug. ***
Comment 3 Kevin Funk 2014-02-11 10:09:24 UTC
Hack to make this work for the moment:

diff --git a/projectmanagers/cmake/cmakecommitchangesjob.cpp b/projectmanagers/cmake/cmakecommitchangesjob.cpp
index e7b9d4e..82abd2c 100644
--- a/projectmanagers/cmake/cmakecommitchangesjob.cpp
+++ b/projectmanagers/cmake/cmakecommitchangesjob.cpp
@@ -135,8 +135,8 @@ void processDependencies(ProcessedTarget &target, const QString& dep, const CMak
 
     target.includes += depData["INTERFACE_INCLUDE_DIRECTORIES"];
     target.defines += depData["INTERFACE_COMPILE_DEFINITIONS"];
-    foreach(const QString& d, depData["INTERFACE_LINK_LIBRARIES"])
-        processDependencies(target, d, data);
+//    foreach(const QString& d, depData["INTERFACE_LINK_LIBRARIES"])
+//        processDependencies(target, d, data);
 }

Raising importance, this makes KDevelop completely useless for some projects.
Comment 4 Milian Wolff 2014-02-11 10:46:58 UTC
A simple QSet recursion guard should be added to ensure we do not recurse into already handled dependencies to fix this. How hard can it be™
Comment 5 Nick Savoiu 2014-04-09 16:38:08 UTC
Created attachment 86018 [details]
New crash information added by DrKonqi

kdevelop (4.6.0) on KDE Platform 4.11.5 using Qt 4.8.5

- What I was doing when the application crashed:

I was just closing KDevelop after opening it and creating a dummy "hello world" c++ cmake project.

-- Backtrace (Reduced):
#7  0xa637430d in CMakeImportJob::initialize() () from /usr/lib/kde4/kdevcmakemanager.so
#8  0xa6374691 in QtConcurrent::VoidStoredMemberFunctionPointerCall0<void, CMakeImportJob>::runFunctor() () from /usr/lib/kde4/kdevcmakemanager.so
#9  0xa6374719 in QtConcurrent::RunFunctionTask<void>::run() () from /usr/lib/kde4/kdevcmakemanager.so
#10 0xb6432170 in QThreadPoolThread::run() () from /lib/libQtCore.so.4
#11 0xb643f380 in QThreadPrivate::start(void*) () from /lib/libQtCore.so.4
Comment 6 Milian Wolff 2014-07-04 09:16:38 UTC
This now works for me in current master / kdevelop 4.7 with the example provided above. Can someone still reproduce it with a recent checkout?