Bug 271518

Summary: Invalid CMake script causes crash
Product: [Applications] kdevelop Reporter: Safety0ff <zgzlzhui>
Component: Build tools: CMakeAssignee: kdevelop-bugs-null
Status: RESOLVED FIXED    
Severity: crash    
Priority: NOR    
Version: 4.2.1   
Target Milestone: 4.2.0   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Example1
Example2
Backtrace
Example2

Description Safety0ff 2011-04-22 22:30:32 UTC
Created attachment 59222 [details]
Example1

Version:           4.2.1 (using KDE 4.6.2) 
OS:                Linux

If you're have an invalid cmake script and kdevelop tries to parse it can crash.

So far I've found two cases where this happens, but my attempts to reduce it to minimal examples have failed (so my apologies that the test files are large).

The first example has a unterminated if statement (see line 90 in attached CMakeListsCrash.txt)
I actually encountered this when I minimized KDevelop to look at the CMake docs.

The second example is a unterminated string (see line 90 in attached CMakeListsCrash2.txt)

I've attached the backtrace for the first example (the second one give an identical bt).

Note: I used KDevelop 4.2.2 despite putting 4.2.1 in the version field. Also it was compiled from portage.

Reproducible: Always

Steps to Reproduce:
Rename the attached files to CMakeLists.txt (so that kdevelop tries to parse it)
and open them in KDevelop.

Actual Results:  
Crashes, also, it will try to parse the file when it re-opens the session, so you have to go in and fix the CMakeLists.txt with another editor.

Expected Results:  
Not crash, maybe hint at a syntax error?

64 bit linux 2.6.39-rc4
CPU: Core i7-2630qm
GCC 4.5.2
C/CXXFLAGS: -march=native -mtune=generic -mfpmath=sse -O1 -pipe -ggdb
Comment 1 Safety0ff 2011-04-22 22:31:29 UTC
Created attachment 59223 [details]
Example2
Comment 2 Safety0ff 2011-04-22 22:32:01 UTC
Created attachment 59224 [details]
Backtrace
Comment 3 Safety0ff 2011-04-22 22:35:23 UTC
Created attachment 59225 [details]
Example2

Proper example2 file.
Comment 4 Olivier.jg 2011-08-21 09:02:32 UTC
Git commit 58d96d547b3f46614866f7d75f55e69de5cb0804 by Olivier JG.
Committed on 21/08/2011 at 10:58.
Pushed by olivierjg into branch 'master'.

Use QList by index instead of iterators which can be invalidated in some
cases. Add test.
BUG:271518

M  +10   -18   projectmanagers/cmake/parser/cmakeprojectvisitor.cpp
M  +9    -0    projectmanagers/cmake/tests/cmake_cmakeprojectvisitor_test.cpp

http://commits.kde.org/kdevelop/58d96d547b3f46614866f7d75f55e69de5cb0804