View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015424CMakeCMakepublic2015-02-27 10:382015-11-02 09:13
ReporterPaul Martin 
Assigned ToBrad King 
PrioritynormalSeveritycrashReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSLinuxOS Version3.19
Product VersionCMake 3.1.3 
Target VersionCMake 3.2Fixed in VersionCMake 3.2 
Summary0015424: Infinite loop in cmsys::SystemTools::CopyFileAlways
DescriptionWith some (recent) C++ libraries, "failbit" is not set on EOF, hence the while loop in cmsys::SystemTools::CopyFileAlways() never exits.
TagsNo tags attached.
Attached Filespatch file icon cmake_copyfilealways.patch [^] (887 bytes) 2015-02-27 10:38 [Show Content]

 Relationships

  Notes
(0038094)
Brad King (manager)
2015-02-27 10:53

Thanks. IIUC the failbit should only be set when trying to read past EOF, as in the first attempt to read bytes after the last byte in the file was previously read.

Can you tell me which stream library is at fault here? The existing workaround is for a stream library from the 1990s. One might have thought modern C++ implementors would know how to read to end of file correctly. It seems like a common operation ;)

Anyway, based on your approach I've made a similar change to upstream KWSys here:

 http://review.source.kitware.com/19352 [^]

Please try that out.
(0038095)
Paul Martin (reporter)
2015-02-27 11:06

I really don't think code obfuscation is a move in the right direction here.

Lazy boolean evaluation combined with the comma operator is not a recipe for long term code maintainability.

For reference, the C++ library is from gcc 4.9.2.
(0038096)
Brad King (manager)
2015-02-27 11:14

Re 0015424:0038095: Okay, I changed it to your exact patch.

Is this a known bug in gcc 4.9.2's stream library that has been addressed, or were we actually doing something non-standard here?
(0038134)
Brad King (manager)
2015-03-02 09:05

The change has been merged to upstream KWSys. I've now updated KWSys within CMake to get the change:

 KWSys 2015-02-27 (d2aa1afd)
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7c9afb57 [^]
(0038139)
Brad King (manager)
2015-03-03 08:51

The change has been backported in CMake to the 'release' branch:

 KWSys SystemTools: Update CopyFileAlways stream library workarounds
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b8ea771b [^]
(0039720)
Robert Maynard (manager)
2015-11-02 09:13

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

 Issue History
Date Modified Username Field Change
2015-02-27 10:38 Paul Martin New Issue
2015-02-27 10:38 Paul Martin File Added: cmake_copyfilealways.patch
2015-02-27 10:53 Brad King Note Added: 0038094
2015-02-27 10:53 Brad King Assigned To => Brad King
2015-02-27 10:53 Brad King Status new => assigned
2015-02-27 10:53 Brad King Target Version => CMake 3.2
2015-02-27 11:06 Paul Martin Note Added: 0038095
2015-02-27 11:14 Brad King Note Added: 0038096
2015-03-02 09:05 Brad King Note Added: 0038134
2015-03-03 08:51 Brad King Note Added: 0038139
2015-03-03 08:52 Brad King Status assigned => resolved
2015-03-03 08:52 Brad King Resolution open => fixed
2015-03-03 08:52 Brad King Fixed in Version => CMake 3.2
2015-11-02 09:13 Robert Maynard Note Added: 0039720
2015-11-02 09:13 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team