C++ &引用;R6010-abort()已被调用;运行时在文件I/O函数中引发错误

C++ &引用;R6010-abort()已被调用;运行时在文件I/O函数中引发错误,c++,visual-studio,debugging,fstream,C++,Visual Studio,Debugging,Fstream,我有一个程序,将信息写入文本文件,然后读取这些文本文件,再次访问数据。我已经编译了二进制文件,除了得到一个“Debug Error!”…R6010-abort()在将一定数量的二进制文件读回程序后被称为“Error” 读取功能的相关部分如下所示: // file_name is passed by reference in as a parameter of type const std::string& std::fstream text_file(file_name, std::io

我有一个程序,将信息写入文本文件,然后读取这些文本文件,再次访问数据。我已经编译了二进制文件,除了得到一个“Debug Error!”…R6010-abort()在将一定数量的二进制文件读回程序后被称为“Error”

读取功能的相关部分如下所示:

// file_name is passed by reference in as a parameter of type const std::string&
std::fstream text_file(file_name, std::ios_base::in | std::ios_base::binary);
CHECK(text_file.is_open()) << file_name;

// height_, width_, and depth_ are class variables of type size_t
char unused_char;
text_file >> width_ >> unused_char >> height_ >> unused_char >> depth_ >>
    unused_char;
std::streampos pos = text_file.tellg();
text_file.close();

// Assertions that width_ height_, and depth_ are positive
CHECK_GT(width_, 0);
CHECK_GT(height_, 0);
CHECK_GT(depth_, 0);

// data is a class variable of type std::vector<T>
data_.resize(width_ * height_ * depth_);

// THIS IS WHERE IT DIES
std::fstream binary_file(file_name,
                           std::ios_base::in | std::ios_base::binary);
CHECK(binary_file.is_open()) << file_name; // 

...

binary_file.close()
//文件名作为const std::string类型的参数通过引用传入&
std::fstream text_文件(文件名,std::ios_base::in | std::ios_base::binary);
检查(text_file.is_open())>宽度>>未使用的字符>>高度>>未使用的字符>>深度>>
未使用的_字符;
std::streampos pos=text_file.tellg();
text_file.close();
//宽度、高度和深度为正的断言
检查\u GT(宽度,0);
检查\u GT(高度,0);
检查\u GT(深度,0);
//数据是std::vector类型的类变量
调整数据大小(宽度×高度×深度);
//这就是它死亡的地方
std::fstream二进制文件(文件名,
std::ios_base::in | std::ios_base::binary);

检查(binary_file.is_open())是否可以用
try…catch
环绕代码,看看是否没有捕获抛出的异常?这确实需要缩小到一个较小的范围。除了好的猜测之外,我们不太可能对我们所知道的信息(我们只知道程序的一半)有所帮助。@MicroVirus:我听到了,相信我,我愿意。不幸的是我不能。除非你有程序的第一块来生成必要的文件,然后你运行它84次,以此类推。。。你不能复制这个。我希望所有这些信息和调用错误的函数对于其他遇到此类问题的人来说都足够了。好吧,问题是这似乎是一个调试断言失败,发生在
fstream
的一部分,但这不是很具体。事实上,它只发生在83个左右的文件之后,这意味着仅仅通过查看83次“正确”运行的函数就无法确定它的位置,除非可以找到一些“明显”的东西,比如堆栈损坏。程序的内存使用率是否很高?除非您编译的是64位,否则您只能使用~4 GB。一个想法是:如果在前50个文件上运行两次,这样您就可以处理100个文件,而实际上只处理(的内容/名称),会发生什么情况前50个文件?你能用一个
try…catch
包围代码,看看你是否没有捕获抛出的异常吗?这确实需要缩小到一个小范围。除了好的猜测之外,我们不太可能对我们所知道的信息(我们只知道程序的一半)有所帮助。@MicroVirus:我听到了,相信我,我愿意。不幸的是我不能。除非你有程序的第一块来生成必要的文件,然后你运行它84次,以此类推。。。你不能复制这个。我希望所有这些信息和调用错误的函数对于其他遇到此类问题的人来说都足够了。好吧,问题是这似乎是一个调试断言失败,发生在
fstream
的一部分,但这不是很具体。事实上,它只发生在83个左右的文件之后,这意味着仅仅通过查看83次“正确”运行的函数就无法确定它的位置,除非可以找到一些“明显”的东西,比如堆栈损坏。程序的内存使用率是否很高?除非您编译的是64位,否则您只能使用~4 GB。一个想法是:如果对前50个文件运行两次,那么会发生什么情况,这样您就可以使用前50个文件的(内容/名称)处理100个文件?
binary_file {_Filebuffer={_Set_eback=0xcccccccc <Error reading characters of string.> _Set_egptr=0xcccccccc <Error reading characters of string.> ...} }    std::basic_fstream<char,std::char_traits<char> >
data_   { size=0 }  std::vector<float,std::allocator<float> >
depth_  3   unsigned int
file_name   "correct\\path\\to\\file84.txt" const std::basic_string<char,std::char_traits<char>,std::allocator<char> > &
height_ 737 unsigned int
width_  1395    unsigned int
msvcr120d.dll!619114fa()    Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for msvcr120d.dll] 
[External Code] 
my_binary.exe!MyClass<float>::Read(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & file_name) Line 118 C++