Bug 271518 - Invalid CMake script causes crash
Summary: Invalid CMake script causes crash
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Build tools: CMake (show other bugs)
Version: 4.2.1
Platform: Gentoo Packages Linux
: NOR crash
Target Milestone: 4.2.0
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-22 22:30 UTC by Safety0ff
Modified: 2011-08-21 09:02 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Example1 (3.45 KB, text/plain)
2011-04-22 22:30 UTC, Safety0ff
Details
Example2 (3.45 KB, text/plain)
2011-04-22 22:31 UTC, Safety0ff
Details
Backtrace (10.01 KB, application/octet-stream)
2011-04-22 22:32 UTC, Safety0ff
Details
Example2 (3.45 KB, text/plain)
2011-04-22 22:35 UTC, Safety0ff
Details

Note You need to log in before you can comment on or make changes to this bug.
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