View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0015572 | CMake | CMake | public | 2015-05-18 08:16 | 2016-01-04 11:51 | ||||
Reporter | Daniel Vrátil | ||||||||
Assigned To | Brad King | ||||||||
Priority | normal | Severity | minor | Reproducibility | always | ||||
Status | closed | Resolution | fixed | ||||||
Platform | Linux | OS | Fedora Linux | OS Version | 22 | ||||
Product Version | CMake 3.2.2 | ||||||||
Target Version | CMake 3.2.3 | Fixed in Version | CMake 3.2.3 | ||||||
Summary | 0015572: Crash when parsing malformed foreach() inside function() | ||||||||
Description | When parsing a malformed CMake script with foreach() inside function(), where the foreach() is not correctly terminated (missing endforeach()), CMake crashes instead of printing an error message. | ||||||||
Steps To Reproduce | Run following script with cmake -P function(printLists) foreach(i ITEMS 1) message(STATUS "Item: ${i}") endfunction() printLists() CMake crashes: cmake: /builddir/build/BUILD/cmake-3.2.2/Source/cmMakefile.cxx:3328: void cmMakefile::PopLoopBlockBarrier(): Assertion `this->LoopBlockCounter.top() == 0' failed. #0 0x00007ffff642ba98 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55 #1 0x00007ffff642d72a in __GI_abort () at abort.c:89 0000002 0x00007ffff6424247 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0x769710 "this->LoopBlockCounter.top() == 0", file=file@entry=0x769690 "/builddir/build/BUILD/cmake-3.2.2/Source/cmMakefile.cxx", line=line@entry=3328, function=function@entry=0x76abe0 <cmMakefile::PopLoopBlockBarrier()::__PRETTY_FUNCTION__> "void cmMakefile::PopLoopBlockBarrier()") at assert.c:92 0000003 0x00007ffff64242f2 in __GI___assert_fail (assertion=0x769710 "this->LoopBlockCounter.top() == 0", file=0x769690 "/builddir/build/BUILD/cmake-3.2.2/Source/cmMakefile.cxx", line=3328, function=0x76abe0 <cmMakefile::PopLoopBlockBarrier()::__PRETTY_FUNCTION__> "void cmMakefile::PopLoopBlockBarrier()") at assert.c:101 0000004 0x00000000004dce45 in cmMakefile::PopLoopBlockBarrier (this=0xa39070) at /usr/src/debug/cmake-3.2.2/Source/cmMakefile.cxx:3328 0000005 0x00000000004e9942 in cmMakefile::PopScope (this=this@entry=0xa39070) at /usr/src/debug/cmake-3.2.2/Source/cmMakefile.cxx:4488 0000006 0x00000000005b4c39 in ~ScopePushPop (this=<synthetic pointer>, __in_chrg=<optimized out>) at /usr/src/debug/cmake-3.2.2/Source/cmMakefile.h:923 0000007 cmFunctionHelperCommand::InvokeInitialPass (this=0xa3f7b0, args=..., inStatus=...) at /usr/src/debug/cmake-3.2.2/Source/cmFunctionCommand.cxx:98 0000008 0x00000000004f3008 in cmMakefile::ExecuteCommand (this=this@entry=0xa39070, lff=..., status=...) at /usr/src/debug/cmake-3.2.2/Source/cmMakefile.cxx:385 #9 0x00000000004f3d3f in cmMakefile::ReadListFile (this=0xa39070, filename_in=filename_in@entry=0x0, external_in=external_in@entry=0xa27498 "test.cmake", fullPath=fullPath@entry=0x0, noPolicyScope=noPolicyScope@entry=true) at /usr/src/debug/cmake-3.2.2/Source/cmMakefile.cxx:666 0000010 0x000000000056736e in cmake::ReadListFile (this=this@entry=0x7fffffffd590, args=..., path=0xa27498 "test.cmake") at /usr/src/debug/cmake-3.2.2/Source/cmake.cxx:508 #11 0x000000000056e8b7 in cmake::SetCacheArgs (this=this@entry=0x7fffffffd590, args=...) at /usr/src/debug/cmake-3.2.2/Source/cmake.cxx:457 0000012 0x00000000005746f6 in cmake::Run (this=this@entry=0x7fffffffd590, args=..., noconfigure=noconfigure@entry=false) at /usr/src/debug/cmake-3.2.2/Source/cmake.cxx:1668 0000013 0x000000000049c0a0 in do_cmake (ac=ac@entry=3, av=av@entry=0xa257d0) at /usr/src/debug/cmake-3.2.2/Source/cmakemain.cxx:327 0000014 0x0000000000497fdd in main (ac=3, av=0xa257d0) at /usr/src/debug/cmake-3.2.2/Source/cmakemain.cxx:193 Even though the script itself is malformed, I would expect CMake to handle the missing endforeach() correctly, like it does outside function(). This is an output from cmake when running the reproducer as above, just use macro()/endmacro() instead of function(): CMake Error in test.cmake: A logical block opening on the line /home/dvratil/test.cmake:2 (foreach) is not closed. | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | |||||||||
Relationships | |
Relationships |
Notes | |
(0038764) Brad King (manager) 2015-05-18 11:17 |
Thanks. Fixed and test added: Fix assertion failure on unmatched foreach in function http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3a656065 [^] |
(0040055) Robert Maynard (manager) 2016-01-04 11:51 |
Closing resolved issues that have not been updated in more than 4 months. |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2015-05-18 08:16 | Daniel Vrátil | New Issue | |
2015-05-18 11:17 | Brad King | Note Added: 0038764 | |
2015-05-18 11:17 | Brad King | Assigned To | => Brad King |
2015-05-18 11:17 | Brad King | Status | new => resolved |
2015-05-18 11:17 | Brad King | Resolution | open => fixed |
2015-05-18 11:17 | Brad King | Fixed in Version | => CMake 3.3 |
2015-05-18 11:17 | Brad King | Target Version | => CMake 3.3 |
2015-06-01 14:47 | Brad King | Fixed in Version | CMake 3.3 => CMake 3.2.3 |
2015-06-01 14:47 | Brad King | Target Version | CMake 3.3 => CMake 3.2.3 |
2016-01-04 11:51 | Robert Maynard | Note Added: 0040055 | |
2016-01-04 11:51 | Robert Maynard | Status | resolved => closed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |