简体   繁体   English

土壤异常C ++

[英]soil exception c++

when I made my game, all went fine, but suddenly I had a weird exception on the load picture of soil. 当我进行游戏时,一切都很好,但是突然之间,我在土壤负荷图上出现了一个奇怪的异常。 It didn't happened in the start of the game, it happened suddenly, it was very weird. 它不是在游戏开始时发生的,而是突然发生的,这很奇怪。

here a picture: http://oi39.tinypic.com/vgj9y.jpg 这是一张图片: http : //oi39.tinypic.com/vgj9y.jpg

here the code: 这里的代码:

bool window::loadTex(std::string fName, int fNum)
{
        textur[fNum] = SOIL_load_OGL_texture
            (
            (char*)fName.c_str(),
            SOIL_LOAD_AUTO,
            SOIL_CREATE_NEW_ID,
            SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y 
            );
        if(textur[fNum] == 0)
            return false;
        return true;
}

and the function call: 和函数调用:

if(!loadTex(std::string("data/back.png"), 0))
        printf("Can't load image");

it is so weird... when the exception happened, I didn't do anything that related to soil. 太奇怪了...发生异常时,我没有做任何与土壤有关的事情。

There is more information about it in the Dissambly, may it help? Dissambly中有关于它的更多信息,这可能有帮助吗?

First-chance exception at 0x784FFDEE (msvcr100.dll) in ConsoleApplication6.exe: 0xC0000005: Access violation reading location 0x00000000.

Fixed! 固定! thanks a lot! 非常感谢!

There's nothing weird about it. 没有什么奇怪的。 You have a run time error. 您有运行时错误。 Probably somewhere in your code you overrun some memory and this is the way the problem manifested itself. 可能是代码中的某个地方超出了一些内存,这就是问题表现出来的方式。 You need to find the problem in your code. 您需要在代码中找到问题。

One way to find the problem is to look with the debugger what is wrong with objects where the crash is. 解决问题的一种方法是使用调试器查看崩溃所在的对象出了什么问题。 Maybe one of the pointers there have invalid value. 可能那里的指针之一具有无效值。 If the address of this pointer that has garbage in it is consistent between runs, you can put a data break point on its address and see, every time you hit the data break point, who is changing it and whether it's an error or normal healthy flow. 如果此指针中包含垃圾的地址在两次运行之间是一致的,则可以在其地址上放置一个数据断点,并查看每次遇到该数据断点时,谁在更改它,以及它是错误还是正常运行状况流。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM