View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0013845CMake(No Category)public2013-01-10 15:122013-06-03 09:05
Reporterrbmj 
Assigned ToBrad King 
PrioritynormalSeveritycrashReproducibilityalways
StatusclosedResolutionfixed 
Platformx86_64-linux-gnuOSDebianOS VersionWheezy
Product VersionCMake 2.8.9 
Target VersionCMake 2.8.11Fixed in VersionCMake 2.8.11 
Summary0013845: CMake segfault if extra newline in link.txt
DescriptionThe origin of this problem was that I was writing/testing a cross toolchain file which made complicated custom link rules. One of the variables in the link rule came from an execute_process command that had a trailing newline and that, because of its positioning, ended up adding a blank line in the link.txt. This causes cmake to segfault.

This may be rare enough that it's not an issue. Also, I don't have the latest and greatest CMake, so it may already be fixed...

Reproducing is easy though:
Steps To ReproduceMake hello.c:

#include <stdio.h>
int main() {
   printf("Hello, World!\n");
   return 0;
}

and CMakeLists.txt:

cmake_minimum_required(VERSION 2.8)
project(hello)
add_executable(hello hello.c)

Go to build directory and run cmake. Then, add a blank line to the beginning of CMakeFiles/hello.dir/link.txt

Run make:

...
Linking C executable hello
Error running link command: Segmentation fault
make[2]: *** [hello] Error 1
make[1]: *** [CMakeFiles/hello.dir/all] Error 2
make: *** [all] Error 2
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0032096)
Brad King (manager)
2013-01-11 09:39

Interesting. It is not actually "cmake -E" that is crashing but the child it forks to try to run the command line. We accidentally do exec() with a NULL argv[0] in the child and then the parent reports that it crashed.

I'll work on two fixes for this. First, the process execution API that parses the command line should not add an empty command. Second, we should not try to execute an empty command line anyway.
(0032097)
Brad King (manager)
2013-01-11 11:05

The second of the fixes I mention in 0013845:0032096 is:

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

and is sufficient to resolve this issue. I'll handle the first (internal API) fix separately.
(0033186)
Robert Maynard (manager)
2013-06-03 09:05

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2013-01-10 15:12 rbmj New Issue
2013-01-11 09:39 Brad King Note Added: 0032096
2013-01-11 09:39 Brad King Assigned To => Brad King
2013-01-11 09:39 Brad King Status new => assigned
2013-01-11 09:39 Brad King Target Version => CMake 2.8.11
2013-01-11 11:05 Brad King Note Added: 0032097
2013-01-11 11:05 Brad King Status assigned => resolved
2013-01-11 11:05 Brad King Resolution open => fixed
2013-01-11 11:05 Brad King Fixed in Version => CMake 2.8.11
2013-06-03 09:05 Robert Maynard Note Added: 0033186
2013-06-03 09:05 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team