Pau*_*ulH 5 c++ windows boost boost-filesystem
我有一个使用在Windows XP SP3中运行的Boost 1.47.0的Visual Studio 2008 C++ 03应用程序.
该调用boost::filesystem::create_directories( L"c:\\foo\\bar" );抛出std::bad_alloc异常.
在输出窗口中,我看到一个调试堆消息:"HEAP [test.exe]:无效的分配大小 - CDCDCDCE(超过7ffdefff)"
callstack显示boost.filesystem在Microsoft标准库文件xlocale第309行中创建新的语言环境和最后一行可见代码.
msvcp90.dll!std::_Allocate<char>() + 0x17 bytes
msvcp90.dll!std::allocator<char>::allocate() + 0xf bytes
msvcp90.dll!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Copy() + 0x70 bytes
msvcp90.dll!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Grow() + 0x26 bytes
msvcp90.dll!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::assign() + 0x50 bytes
msvcp90.dll!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::basic_string<char,std::char_traits<char>,std::allocator<char> >() + 0x24 bytes
msvcp90.dll!std::locale::_Locimp::_Locimp() + 0x47 bytes
> test.exe!std::locale::locale<windows_file_codecvt>(const std::locale & _Loc={...}, const windows_file_codecvt * _Facptr=0x00b48f60) Line 309 + 0x69 bytes C++
test.exe!`anonymous namespace'::default_locale() Line 735 C++
test.exe!`anonymous namespace'::path_locale() Line 777 + 0x2a bytes C++
test.exe!boost::filesystem3::path::wchar_t_codecvt_facet() Line 797 + 0x25 bytes C++
test.exe!boost::filesystem3::path::codecvt() Line 388 + 0x5 bytes C++
test.exe!boost::filesystem3::path::path<wchar_t const *>(const wchar_t * begin=0x00b460f8, const wchar_t * end=0x00b46116) Line 162 + 0x5 bytes C++
test.exe!boost::filesystem3::path::parent_path() Line 313 + 0x57 bytes C++
test.exe!boost::filesystem3::detail::create_directories(const boost::filesystem3::path & p={...}, boost::system::error_code * ec=0x00000000) Line 832 + 0x13 bytes C++
test.exe!boost::filesystem3::create_directories(const boost::filesystem3::path & p={...}) Line 318 + 0x29 bytes C++
test.exe!wmain(int __formal=1, int __formal=1) Line 112 + 0xc bytes C++
test.exe!__tmainCRTStartup() Line 583 + 0x19 bytes C
test.exe!wmainCRTStartup() Line 403 C
kernel32.dll!_BaseProcessStart@4() + 0x23 bytes
Run Code Online (Sandbox Code Playgroud)
任何人都可以建议如何解决这个问题?
编辑我更新为提升1.50.0.问题仍然存在.
这个问题闻起来像是不匹配_SECURE_SCL(或者可能有些相关_HAS_ITERATOR_DEBUGGING- 但我怀疑后者,因为调用堆栈指示非调试构建)。请参阅/sf/answers/427296761/了解一些信息,并确保_SECURE_SCL在构建test.exe和链接的 boost 文件系统库中以相同的方式定义。
AFAIK,boost 将使用 VC 默认值(_SECURE_SCL=1甚至在 VS2008 的发行版中也是如此),所以如果你进行设置,_SECURE_SCL=0这可能是问题所在。
| 归档时间: |
|
| 查看次数: |
1518 次 |
| 最近记录: |