MantisBT - CMake
View Issue Details
0014015CMakeCMakepublic2013-03-15 07:232013-03-16 04:05
Sylwester Arabas 
Eric NOULARD 
normalminoralways
closedwon't fix 
 
 
0014015: execute_process() causing CMake to abort suddenly
Hello, here's an example causing CMake to abort suddenly without printing any useful information.

HTH,
Sylwester
$ cat CMakeLists.txt
execute_process(COMMAND perf stat -oo /dev/null w)
message("HERE")

$ cmake .
-- The C compiler identification is GNU 4.7.2
-- The CXX compiler identification is GNU 4.7.2
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
/dev/null: Permission denied
Terminated
No tags attached.
? test_execute_process_abort.cmake (216) 2013-03-15 07:52
https://public.kitware.com/Bug/file/4681/test_execute_process_abort.cmake
Issue History
2013-03-15 07:23Sylwester ArabasNew Issue
2013-03-15 07:51Eric NOULARDAssigned To => Eric NOULARD
2013-03-15 07:51Eric NOULARDStatusnew => assigned
2013-03-15 07:52Eric NOULARDFile Added: test_execute_process_abort.cmake
2013-03-15 08:08Eric NOULARDNote Added: 0032636
2013-03-15 08:08Eric NOULARDNote Added: 0032637
2013-03-15 08:08Eric NOULARDStatusassigned => feedback
2013-03-15 13:33Sylwester ArabasNote Added: 0032643
2013-03-15 13:33Sylwester ArabasStatusfeedback => assigned
2013-03-15 17:21Eric NOULARDNote Added: 0032644
2013-03-15 18:52Sylwester ArabasNote Added: 0032645
2013-03-16 04:05Eric NOULARDNote Added: 0032646
2013-03-16 04:05Eric NOULARDStatusassigned => closed
2013-03-16 04:05Eric NOULARDResolutionopen => won't fix

Notes
(0032636)
Eric NOULARD   
2013-03-15 08:08   
I guess the culprit is not cmake but the perf command itself.
Try the following command line:

$ perf stat -oo /dev/null

and see what happen you'll see that perf is terminating abruptely.

If you

$ strace -f perf stat -oo /dev/null w

at the end you'll see:
[pid xxxx] kill(0, SIGTERM <unfinished ...>

which basically sends SIFTERM to **all** processes of the process group,
thus killing CMake itself.

I think there is nothing CMake can do about it however the trouble
comes from the typo:

perf stat -oo /dev/null w

which means from the 'perf' command point of view that you are trying
to collect stats for the command "/dev/null" (and put stats inside 'o' file)
if you try:

perf stat -o /dev/null w


you'll see that it works as expected.

I put the bug in feedback status but I guess it should go to won't fix.
(0032637)
Eric NOULARD   
2013-03-15 08:08   
Waiting for feedback before switching and closing.
(0032643)
Sylwester Arabas   
2013-03-15 13:33   
The typo was intentional - it triggers this behaviour. Do you consider it worth reporting to perf maintainers? Killing the parent process seems quite surprising to me.

Thanks,
Sylwester
(0032644)
Eric NOULARD   
2013-03-15 17:21   
I think it's worth asking, at least, because killing
the process group looks like overkill.
(0032645)
Sylwester Arabas   
2013-03-15 18:52   
I've just asked if this behaviour is intentional on the linux-perf-users mailing list. I guess the issue is closed as it has nothing to do with CMake - sorry. Thanks for checking it.
Sylwester
(0032646)
Eric NOULARD   
2013-03-16 04:05   
This is not a CMake issue.