访问违规阅读位置 [英] Access violation reading location

查看:81
本文介绍了访问违规阅读位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误:Hestia_MFC.exe中0x5D8D0918(Hestia.dll)的未处理异常:0xC0000005:访问冲突读取位置0x0C242000。





  for  int  x_temp =  100 ; x_temp<  400 ; x_temp ++){ //   640 x 512  
for int y_temp = 100 ; y_temp< 400 ; y_temp ++){
if ((x_temp% 50 )== 0 &&(y_temp % 50 )== 0 ){

尝试 {
m_Hestia-> GetSpot_C(x_temp,y_temp,Hestia :: CELSIUS,m_TempData,&安培; spot_temp);
}
catch (例外情况){

}

if (spot_temp> max_temp){ // 288 - > 296
max_temp = spot_temp;
max_pointX = x_temp;
max_pointY = y_temp;
}
if (spot_temp< min_temp){
min_temp = spot_temp;
min_pointX = x_temp;
min_pointY = y_temp;
}

}
}





我每隔2秒调用一次此函数。



我不知道为什么我的程序会出现这个错误。



如何修复程序?



我很乐意使用try和catch。它不起作用......帮助我..



我尝试过的事情:



尝试{



} catch(Exception ex){



}

解决方案

猜测 - 我们无法运行你的应用程序就可以了 - 它是 m_Hestia 或你调用它的参数是 GetSpot_C 函数。



使用调试器:在行上放一个断点当它被击中时查看数据:它是否全部有效?如果是这样,请检查参数与另一端的代码,看看它们正在做什么。



抱歉,我们不能做任何对于你。


除了 OriginalGriff <的解决方案1 / a> [ ^ ],我想知道这个:如何调试访问冲突? [ ^ ]

常见问题上述错误消息的原因是您尝试从初始化为 NULL 的变量读取或设置为 NULL 通过分配失败。


引用:

我使用try和catch。它不起作用......帮助我......

另请参阅 c ++ - 捕获访问冲突异常? - Stack Overflow [ ^ ]


error : Unhandled exception at 0x5D8D0918 (Hestia.dll) in Hestia_MFC.exe: 0xC0000005: Access violation reading location 0x0C242000.


for (int x_temp = 100; x_temp < 400; x_temp++) { //640 x 512 
  for (int y_temp = 100; y_temp < 400; y_temp++) {
    if ((x_temp % 50) == 0 && (y_temp % 50) == 0) {
				
	try {
	m_Hestia->GetSpot_C(x_temp, y_temp, Hestia::CELSIUS, m_TempData, &spot_temp);
	}
	catch(Exception ex){

	}

    if (spot_temp > max_temp) {//288 -> 296
       max_temp = spot_temp;
       max_pointX = x_temp;
       max_pointY = y_temp;
    }
    if (spot_temp < min_temp) {
       min_temp = spot_temp;
       min_pointX = x_temp;
       min_pointY = y_temp;
    }

}
}



I call this function every 2 seconds.

I dont know why this error occurs my program.

How can i fix my program?

I aleady use try and catch. It is not working ... help me ..

What I have tried:

try{

}catch(Exception ex){

}

解决方案

At a guess - and we can't run your app so that's all it can be - it's either m_Hestia or the parameters of your call to it's GetSpot_C function.

Use the debugger: put a breakpoint on the line and when it gets hit look at the data: is it all valid? If so, check the parameters with the code at the other end, and see what it is doing with them.

Sorry, but we can't do any of that for you.


In addition to solution 1 by OriginalGriff[^], i'd suggeest to read this: How Can I Debug an Access Violation?[^]
The common reason of above error message is that you're trying to read from a variable initialised to NULL or set to NULL through a failed allocation.


Quote:

I aleady use try and catch. It is not working ... help me ..

See also c++ - Catching access violation exceptions? - Stack Overflow[^].


这篇关于访问违规阅读位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆