MantisBT - CMake
View Issue Details
0013138CMakeCMakepublic2012-04-16 16:242013-01-09 10:55
Andras Lasso 
Brad King 
normalcrashalways
closedfixed 
Windows7 64-bit
CMake 2.8.7 
CMake 2.8.9CMake 2.8.9 
0013138: CMake crashes in cmListCommand::HandleInsertCommand
CMake crashes when trying to build a Slicer 4.1 extension. The problem is reproducible with CMake-2.8.8-rc2.

The CMake build scripts are quite complex, so there might be some error in the scripts, but anyway CMake reject the execution of the invalid command and print a meaningful error message instead of crashing.

The same build completes without problems on several computers, CMake crashes only on one computer.
InvokeInitialPass (in cmcommand.h) is called with the following arguments:
args[0]="INSERT"
args[1]="Slicer_LAUNCH_COMMAND"
args[2]="${launch_index}"
args[3]="--launcher-additional-settings"
args[4]="${Slicer_ADDITIONAL_LAUNCHER_SETTINGS}"

after this->Makefile->ExpandArguments(args, expandedArguments)

expandedArguments[0]="INSERT"
expandedArguments[1]="Slicer_LAUNCH_COMMAND"
expandedArguments[2]="-1"
expandedArguments[3]="--launcher-additional-settings"
expandedArguments[4]="E:/src/cmake-2.8.7-vs2005/Source/AdditionalLauncherSettings.ini"

Note that expandedArguments[2]="-1" => this doesn't seem to be correct.

After this cmListCommand::HandleInsertCommand is called, and in that

int item = atoi(args[2].c_str());

=> item = -1

CMake then crashes in the same function at this line:

varArgsExpanded.insert(varArgsExpanded.begin()+item+cnt, args[cc]);

If I change item to 0 then there is no crash.
No tags attached.
Issue History
2012-04-16 16:24Andras LassoNew Issue
2012-04-16 16:59Brad KingNote Added: 0029192
2012-04-17 11:11Brad KingNote Added: 0029202
2012-04-17 11:11Brad KingStatusnew => resolved
2012-04-17 11:11Brad KingResolutionopen => fixed
2012-04-17 11:11Brad KingAssigned To => Brad King
2012-08-09 16:59David ColeFixed in Version => CMake 2.8.9
2012-08-09 16:59David ColeTarget Version => CMake 2.8.9
2013-01-09 10:55Robert MaynardNote Added: 0032021
2013-01-09 10:55Robert MaynardStatusresolved => closed

Notes
(0029192)
Brad King   
2012-04-16 16:59   
I can reproduce the crash with the code

set(mylist "")
list(INSERT mylist -1 x)


The implementation of list(INSERT) was added here:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f87271d0 [^]
  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ed1ea24c [^]

It does not check for the case that a list is defined but empty and a python-style negative index is used.
(0029202)
Brad King   
2012-04-17 11:11   
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=05604eb9 [^]
(0032021)
Robert Maynard   
2013-01-09 10:55   
Closing resolved issues that have not been updated in more than 4 months.