MantisBT - CMake
View Issue Details
0015589CMakeCMakepublic2015-05-27 16:262015-11-02 09:15
Martyn Gigg 
Brad King 
normalcrashalways
closedfixed 
Windows7
CMake 3.2.2 
CMake 3.3CMake 3.3 
0015589: Crash when fetching larger data file with External Data on Windows
We have been using the external data mechanism with great success for several months.

Recently, an 800Mb file was added to our test data and on Windows cmake crashes with a std::bad_alloc during a curl callback. The download works fine on Linux and Mac OS X.

The full stack trace from Visual Studio is:

> msvcr110d.dll!_CxxThrowException(void * pExceptionObject, const _s__ThrowInfo * pThrowInfo) Line 152 C++
     msvcr110d.dll!operator new(unsigned int size) Line 63 C++
     cmake.exe!std::_Allocate<char>(unsigned int _Count, char * __formal) Line 28 C++
     cmake.exe!std::allocator<char>::allocate(unsigned int _Count) Line 591 C++
     cmake.exe!std::_Wrap_alloc<std::allocator<char> >::allocate(unsigned int _Count) Line 877 C++
     cmake.exe!std::vector<char,std::allocator<char> >::_Insert<char *>(std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<char> > > _Where, char * _First, char * _Last, std::forward_iterator_tag __formal) Line 1316 C++
     cmake.exe!std::vector<char,std::allocator<char> >::insert<char *>(std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<char> > > _Where, char * _First, char * _Last) Line 1262 C++
     cmake.exe!`anonymous namespace'::cmFileCommandCurlDebugCallback(void * __formal, curl_infotype __formal, char * chPtr, unsigned int size, void * data) Line 2519 C++
     cmake.exe!showit(SessionHandle * data, curl_infotype type, char * ptr, unsigned int size) Line 608 C
     cmake.exe!Curl_debug(SessionHandle * data, curl_infotype type, char * ptr, unsigned int size, connectdata * conn) Line 661 C
     cmake.exe!Curl_readwrite(connectdata * conn, unsigned char * done) Line 1208 C
     cmake.exe!Transfer(connectdata * conn) Line 1819 C
     cmake.exe!Curl_perform(SessionHandle * data) Line 2378 C
     cmake.exe!curl_easy_perform(void * curl) Line 480 C
     cmake.exe!cmFileCommand::HandleDownloadCommand(const std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > & args) Line 2946 C++
     cmake.exe!cmFileCommand::InitialPass(const std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > & args, cmExecutionStatus & __formal) Line 83 C++
     cmake.exe!cmCommand::InvokeInitialPass(const std::vector<cmListFileArgument,std::allocator<cmListFileArgument> > & args, cmExecutionStatus & status) Line 68 C++
     cmake.exe!cmMakefile::ExecuteCommand(const cmListFileFunction & lff, cmExecutionStatus & status) Line 418 C++
     cmake.exe!cmWhileFunctionBlocker::IsFunctionBlocked(const cmListFileFunction & lff, cmMakefile & mf, cmExecutionStatus & inStatus) Line 73 C++
     cmake.exe!cmMakefile::IsFunctionBlocked(const cmListFileFunction & lff, cmExecutionStatus & status) Line 2833 C++
     cmake.exe!cmMakefile::ExecuteCommand(const cmListFileFunction & lff, cmExecutionStatus & status) Line 386 C++
     cmake.exe!cmFunctionHelperCommand::InvokeInitialPass(const std::vector<cmListFileArgument,std::allocator<cmListFileArgument> > & args, cmExecutionStatus & inStatus) Line 179 C++
     cmake.exe!cmMakefile::ExecuteCommand(const cmListFileFunction & lff, cmExecutionStatus & status) Line 418 C++
     cmake.exe!cmForEachFunctionBlocker::IsFunctionBlocked(const cmListFileFunction & lff, cmMakefile & mf, cmExecutionStatus & inStatus) Line 57 C++
     cmake.exe!cmMakefile::IsFunctionBlocked(const cmListFileFunction & lff, cmExecutionStatus & status) Line 2833 C++
     cmake.exe!cmMakefile::ExecuteCommand(const cmListFileFunction & lff, cmExecutionStatus & status) Line 386 C++
     cmake.exe!cmFunctionHelperCommand::InvokeInitialPass(const std::vector<cmListFileArgument,std::allocator<cmListFileArgument> > & args, cmExecutionStatus & inStatus) Line 179 C++
     cmake.exe!cmMakefile::ExecuteCommand(const cmListFileFunction & lff, cmExecutionStatus & status) Line 418 C++
     cmake.exe!cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction & lff, cmMakefile & mf, cmExecutionStatus & inStatus) Line 140 C++
     cmake.exe!cmMakefile::IsFunctionBlocked(const cmListFileFunction & lff, cmExecutionStatus & status) Line 2833 C++
     cmake.exe!cmMakefile::ExecuteCommand(const cmListFileFunction & lff, cmExecutionStatus & status) Line 386 C++
     cmake.exe!cmMakefile::ReadListFile(const char * filename_in, const char * external_in, std::basic_string<char,std::char_traits<char>,std::allocator<char> > * fullPath, bool noPolicyScope) Line 699 C++
     cmake.exe!cmake::ReadListFile(const std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > & args, const char * path) Line 551 C++
     cmake.exe!cmake::SetCacheArgs(const std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > & args) Line 501 C++
     cmake.exe!cmake::Run(const std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > & args, bool noconfigure) Line 2516 C++
     cmake.exe!do_cmake(int ac, char * * av) Line 532 C++
     cmake.exe!main(int ac, char * * av) Line 343 C++
     cmake.exe!__tmainCRTStartup() Line 536 C
     cmake.exe!mainCRTStartup() Line 377 C
     kernel32.dll!74ed336a() Unknown
     ntdll.dll!772292b2() Unknown
     ntdll.dll!77229285() Unknown

The insert line in cmFileCommand.cxx::cmFileCommandCurlDebugCallback causes a memory allocation error.
I have placed an isolated test project at https://github.com/martyngigg/external-data-win32-crash [^] that reproduces the error using one of our large files.

Running cmake on the project and then building with

msbuild ExternalDataTest.sln

will reproduce the issue.
No tags attached.
Issue History
2015-05-27 16:26Martyn GiggNew Issue
2015-05-28 11:08Brad KingNote Added: 0038810
2015-05-28 11:08Brad KingAssigned To => Brad King
2015-05-28 11:08Brad KingStatusnew => resolved
2015-05-28 11:08Brad KingResolutionopen => fixed
2015-05-28 11:08Brad KingFixed in Version => CMake 3.3
2015-05-28 11:08Brad KingTarget Version => CMake 3.3
2015-05-28 11:11Brad KingNote Edited: 0038810bug_revision_view_page.php?bugnote_id=38810#r1790
2015-11-02 09:15Robert MaynardNote Added: 0039827
2015-11-02 09:15Robert MaynardStatusresolved => closed

Notes
(0038810)
Brad King   
2015-05-28 11:08   
(edited on: 2015-05-28 11:11)
This should fix it:

 cmFileCommand: Do not log raw protocol data from curl
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=eba12a43 [^]

(0039827)
Robert Maynard   
2015-11-02 09:15   
Closing resolved issues that have not been updated in more than 4 months.