MantisBT - CMake
View Issue Details
0014005CMakeCMakepublic2013-03-12 16:532013-10-07 10:03
Alexander Polunin 
Brad King 
normalminoralways
closedfixed 
CMake 2.8.10.2 
CMake 2.8.11CMake 2.8.11 
0014005: terminate called after throwing an instance of 'std::logic_error'
cmake source files contain places where you construct std::basic_string from NULL pointer of type const char*. And this leads to cmake termination after throwing std::logic_error exception. Maybe it's not the big problem if you sure that NULL pointers are impossible but at least in one case simple input to cmake leads to its termination in string "cmake-2.8.10.2/Source/kwsys/SystemTools.cxx:1803".

kwsys_stl::string SystemTools::ConvertToUnixOutputPath(const char* path)
{
  kwsys_stl::string ret = path; // maybe we need to more strict check here
...................................
1) create CMakeLists.txt with content

################Begin##################
include (CTest)
project(ttt)
################End#####################

2) create build folder and go there
3) run cmake with default generator (I have checked it with gcc and MinGW toolchain)
 cmake ..

4) see
terminate called after throwing an instance of 'std::logic_error'
  what(): basic_string::_S_construct null not valid
No tags attached.
Issue History
2013-03-12 16:53Alexander PoluninNew Issue
2013-03-12 18:34Brad KingNote Added: 0032596
2013-03-12 18:34Brad KingAssigned To => Brad King
2013-03-12 18:34Brad KingStatusnew => resolved
2013-03-12 18:34Brad KingResolutionopen => fixed
2013-03-12 18:34Brad KingFixed in Version => CMake 2.8.11
2013-03-12 18:34Brad KingTarget Version => CMake 2.8.11
2013-10-07 10:03Robert MaynardNote Added: 0033993
2013-10-07 10:03Robert MaynardStatusresolved => closed

Notes
(0032596)
Brad King   
2013-03-12 18:34   
Combinations of std::string and const char* are rampant throughout CMake internally. Most places are careful not to construct std::string from NULL.

I refactored the RunCMake.build_command test to allow more cases:

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

Then I fixed this crash and added a test:

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

Then I fixed a related problem and added a test:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d90f49b8 [^]
(0033993)
Robert Maynard   
2013-10-07 10:03   
Closing resolved issues that have not been updated in more than 4 months.