[cmake-developers] [CMake 0013106]: SystemTools::CopyFileAlways fails at random due to invalid kwsys_ios::ifstream fin

Mantis Bug Tracker mantis at public.kitware.com
Fri Apr 6 05:03:31 EDT 2012


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=13106 
====================================================================== 
Reported By:                tfischer
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   13106
Category:                   CMake
Reproducibility:            random
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2012-04-06 05:03 EDT
Last Modified:              2012-04-06 05:03 EDT
====================================================================== 
Summary:                    SystemTools::CopyFileAlways fails at random due to
invalid kwsys_ios::ifstream fin
Description: 
I am using a custom cmake script to determine the SVN revision number of my
source code during build time and to write this version number into a file
"version.h" so that the compiler can include the version string into the
compiled code.
The script works as follows: First, it determines the SVN revision (svnversion
or environment variable) and writes a small header file called version.h.tmp. To
avoid unnecessary recompilations, cmake's copy_if_different is used to copy
version.h.tmp to version.h only if the SVN revision (therefore the file's
content) has changed.

When testing the script, in irregular intervals the copy_if_different call fails
with error message:
Error copying file (if different) from
"/home/tf/programming/gna/qtcreator-build/src/parts/version.h.tmp" to
"/home/tf/programming/gna/qtcreator-build/src/parts/version.h".
I added print statements before each "return false" statement in
SystemTools::CopyFileAlways (eventually called by copy_if_different) to check
which test fails. As it turns out, the test for !fin fails in line 1849 (for
CMake 2.8.6).

The problem now is, that this failure does not follow any pattern as far as I
can see. Running my custom script (attached to this report) 20 times in a loop
(bash for-loop), the following output is generated.

-- SVN version was set outside through environment variable SVN_REV
-- SVN version is AAA
-- SVN version was set outside through environment variable SVN_REV
-- SVN version is AAA
-- SVN version was set outside through environment variable SVN_REV
-- SVN version is AAA
kwsys_ios::ifstream fin is NULL
Error copying file (if different) from
"/home/tf/programming/gna/qtcreator-build/src/parts/version.h.tmp" to
"/home/tf/programming/gna/qtcreator-build/src/parts/version.h".
-- SVN version was set outside through environment variable SVN_REV
-- SVN version is AAA
-- SVN version was set outside through environment variable SVN_REV
-- SVN version is AAA
-- SVN version was set outside through environment variable SVN_REV
-- SVN version is AAA
-- SVN version was set outside through environment variable SVN_REV
-- SVN version is AAA
kwsys_ios::ifstream fin is NULL
Error copying file (if different) from
"/home/tf/programming/gna/qtcreator-build/src/parts/version.h.tmp" to
"/home/tf/programming/gna/qtcreator-build/src/parts/version.h".
-- SVN version was set outside through environment variable SVN_REV
-- SVN version is AAA
-- SVN version was set outside through environment variable SVN_REV
-- SVN version is AAA
-- SVN version was set outside through environment variable SVN_REV
-- SVN version is AAA
-- SVN version was set outside through environment variable SVN_REV
-- SVN version is AAA
-- SVN version was set outside through environment variable SVN_REV
-- SVN version is AAA
-- SVN version was set outside through environment variable SVN_REV
-- SVN version is AAA
-- SVN version was set outside through environment variable SVN_REV
-- SVN version is AAA
-- SVN version was set outside through environment variable SVN_REV
-- SVN version is AAA
-- SVN version was set outside through environment variable SVN_REV
-- SVN version is AAA
-- SVN version was set outside through environment variable SVN_REV
-- SVN version is AAA
-- SVN version was set outside through environment variable SVN_REV
-- SVN version is AAA
-- SVN version was set outside through environment variable SVN_REV
-- SVN version is AAA
-- SVN version was set outside through environment variable SVN_REV
-- SVN version is AAA
kwsys_ios::ifstream fin is NULL
Error copying file (if different) from
"/home/tf/programming/gna/qtcreator-build/src/parts/version.h.tmp" to
"/home/tf/programming/gna/qtcreator-build/src/parts/version.h".

The for-loop to call this script is:
for n in {1..20} ; do /usr/bin/cmake
-DSOURCE_DIR=/home/tf/programming/gna/proj/src/parts
-DBINARY_DIR=/home/tf/programming/gna/qtcreator-build/src/parts -P
/home/tf/programming/gna/proj/src/getsvn.cmake ; done

Any ideas what could cause this behaviour? How to debug/trace this problem?

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2012-04-06 05:03 tfischer       New Issue                                    
2012-04-06 05:03 tfischer       File Added: getsvn.cmake                     
======================================================================




More information about the cmake-developers mailing list