问题描述
一整天都想弄清楚这一点.
Been trying to figure this one out all day.
...
_HISTORY tempHist;
for(int i = 0; i < info.LogPerRecs; i++)
{
CString msg;
msg.Format("History #%d being allocated..",i);
log.Write_Log_File(msg);
tempHist = new History();
msg.Format("New History allocated at %d",tempHist);
log.Write_Log_File(msg);
...
日志说...
"
2010年7月22日13:39:56>已分配历史记录20..
2010年7月22日13:39:56>开始历史构造函数
2010年7月22日13:39:56>完成历史构造函数
2010年7月22日13:39:56>分配给13046208的新历史记录
07/22/2010 13:39:56>分配了历史记录21..
2010年7月22日13:39:56>开始历史构造函数
2010年7月22日13:39:56>完成历史构造函数
2010年7月22日13:39:56>分配了新历史记录的13046384
07/22/2010 13:39:56>分配了历史记录22..
"
然后它爆炸并显示一个错误,
"0x7c911689"处的指令引用了"0x00000000"处的存储器.该存储器无法读取""
但是,我的日志语句之间唯一的代码段是动态分配,从我以前分配的地址来看,我并没有完全在地址上刮掉桶的底部.
历史记录类包含大约35个浮点数,里面没有任何巧妙的内容,_HISTORY是指向该历史记录类的指针的typedef.
代码在调试中工作良好,已发布版本.有什么想法吗?
Log says...
"
07/22/2010 13:39:56>History #20 being allocated..
07/22/2010 13:39:56>Beginning History Constructor
07/22/2010 13:39:56>Finishing History Constructor
07/22/2010 13:39:56>New History allocated at 13046208
07/22/2010 13:39:56>History #21 being allocated..
07/22/2010 13:39:56>Beginning History Constructor
07/22/2010 13:39:56>Finishing History Constructor
07/22/2010 13:39:56>New History allocated at 13046384
07/22/2010 13:39:56>History #22 being allocated..
"
And then it blows up with an error that says,
"The instruction at "0x7c911689" referenced memory at "0x00000000". The memory could not be "read""
Yet the only blob of code between my log statements is the dynamic allocation, and judging by the addresses of my previous allocations, I''m not exactly scraping the bottom of the barrel on addresses.
History class contains about 35 floats, nothing clever whatsoever inside of it, _HISTORY is a typedef for a pointer to said History class.
Code works fine in debug, has kittens in release. Any thoughts?
推荐答案
...
_HISTORY tempHist;
for(int i = 0; i < info.LogPerRecs; i++)
{
CString msg;
msg.Format("History #%d being allocated..",i);
log.Write_Log_File(msg);
tempHist = new History();
msg.Format("New History allocated at %d",tempHist);
log.Write_Log_File(msg);
...
...
delete tempHist;
tempHist = 0;
}
这篇关于新尝试访问0x00000000?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!