小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

JVM terminated. Exit code -1073741819

 9loong 2012-09-11

When I run a program using the read part of fstream, I get this return value:

-1073741819

the actual function is part of a corrupt for loop, which I will try to explain:

for(int i = 0; i < vrs_top_i * 3; i += 3)
{
       
int X1x = FileRead(file2, i + 1);
       
int X1y = FileRead(file2, i + 2);
       
char X1sym = FileRead(file2, i + 3);
        viral_data
.add(new X1(X1x, X1y, X1sym));
}

vrs_top_i is a variable declared like this: int vrs_top_i = FileRead(file2, 0);

add is a function for a custom list I made, essentially the same as push_back() for vectors. X1 is a class I made with a constructor that takes three arguments, two ints and a char.

Now for the corrupt part of the loop:

now, when I put "exit(0);" under the third line of the loop "char X1sym...+ 3);" (or anywhere else in the loop, for that matter) It does what you expect: ends the program with a return value of zero.

but when I put "if(i == 0)exit(0);", or "if(i == 3)", I get the aforementioned return value.

So I'm guessing that means that i is never 0 or 3.

So does anybody know what the return value means?

NB: FileRead is declared like so:

int FileRead(std::fstream& file, int pos)
{
int data;
file
.seekg(file.beg + pos * sizeof(int));
file
.read(reinterpret_cast<char*>(&data), sizeof(data));
return data;
}

-1073741819 is the decimal representation of 0xC0000005. This is not actually a return value--it's a Windows code for STATUS_ACCESS_VIOLATION, which is what happens when your program accesses invalid memory.

Effectively, your program has a bug and is accessing invalid memory and crashes. The code that you're seeing is Windows' way of telling you so.

share|improve this answer

Convert it to hex and you'll get 0xc0000005. An error code you should get to know well. It's a general protection fault, or dereferencing a garbage pointer in other words.

share|improve this answer

At least one the reason your code doesn' work as intended:

Your FileRead reads i-th int from a file. But you are using it to read a char, which breaks the math of calculating your addresses. Your record length is not 3 * sizeof(int), but 2 * sizeof(int) + sizeof(char).

In other words, your seekg will be set to an incorrect position after the reading of a char.

share|improve this answer


(###)

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶(hù) 評(píng)論公約

    類(lèi)似文章 更多