“R6010 - abort()被称为”文件I / O函数

时间:2016-06-13 14:33:30

标签: c++ visual-studio debugging fstream

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

阅读功能的相关部分如下:

// 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()

我似乎无法弄清楚发生了什么。对于前83个文件,一切正常,然后在文件84上,我收到此错误。

我尝试了什么:

  • 起初我正在写作然后再读(然后再写)同一个文件。想想也许这是一个锁定问题,第二次写入有一个不同的前缀。没有解决它。
  • 最初,第一次写入是在Linux机器上完成的(我移动了项目)。我想也许这是行结尾的问题,所以我在Windows上重新生成文件。没有解决它。 (虽然值得注意的是我在Ubuntu 14.04上运行它没有任何问题)
  • 我虽然可能文件84是问题,所以我让程序跳过它并转到文件85.仍然抛出错误。当我将文件总数减少到50时,它运行正常。这表明它与文件数量有关,而与内容无关。
  • 我认为它可能是文件句柄问题,但所有打开的流都在此函数中关闭
  • 我尝试在Visual Studio 2013中进行调试。在错误的断点处,变量是:

    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
    

该文件的路径是100%正确的,所以它不是找不到它。我认为“错误阅读字符串字符”的说法特别不祥,但我无法理解它的含义。

  • 最后,从错误开始的堆栈读取:

    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++
    

这些其他SO问题(hereherehere等)表明此错误是由多种原因引起的。

它不应该是内存或空间问题。这在只有12GB RAM的Linux机器上运行良好。现在它是一台增压的Windows机器,拥有超过200 + GB的RAM。此计算具有多TB的可用硬盘空间。我也在从我拥有完全权限的目录中读/写/执行。

我在Windows 8.1上运行它,使用Visual Studio 2013编译。我尝试安装CDB和NTSD,但"Invalid Path to Symbols" issue对我来说是一个巨大的绊脚石。

非常感谢您提供的任何帮助。

0 个答案:

没有答案
相关问题