Access violation reading location 0x000000XX
来源:互联网 发布:什么英语口语软件好 编辑:程序博客网 时间:2024/06/06 00:09
对于这样的运行时错误,你可能会抓狂。我今天在编写MFC程序时遇到了这样的错误,解决这个问题花了我一个多小时的时间,最后才定位到错误。
首先解释一下这种错误,意思是:违反规则访问地址为0x00000038的内存,并且你没有处理这个异常。
一般来说,这种错误产生的原因是:你使用了没有初始化的指针,或者说你初始化NULL,但它没有被赋予实际的值。例如:View*pView=NULL; pView->Update();此时你便会遇到这种错误。你要想解决这种错误,就要找到它的位置。对于MFC程序,你肯定是因为触发了某个事件,才产生了这种错误。你首先要找到与该事件相关联的函数,然后在此处设置断点。然后你就F10,F10,F10就行了。直到错误重新产生。现在你就找到了错误的大概位置。如果这个位置就是你要找的,你解决它就行了,如果不是,那么它应该就是一个函数了。这是你改变断点到此,然后F11进去,继续就行了。一般来说,这种错误这样很容易就找到了错误的原因,但是今天我遇到了一种情况。错误产生在SendMessage()这个函数在,这就麻烦了,因为SendMessage()是直到消息处理完了,它才结束。这时你就要用到错误产生时,它给你定位的地址了,你将断点直接设到这个位置。然后顺着它往前找,或者你可以利用Call Stack来慢慢寻找。希望你可以解决你自己的问题。
以上内容转自:http://hi.baidu.com/supermain/blog/item/7d8240ee133375dd2e2e210b.html
今天遇到的问题是
for(i = m_cUndo.GetSize() - 1; i >= m_nCurUndo; i--)
{
delete m_cUndo[i];
////m_cUndo.RemoveAt(i);
} 这是修改bug后添加的,就是将m_cUndo置空,使它里面的数据为空.如果不加,就成了野指针了.
m_cUndo.Add(new CUndoViaExtending(dlg.pExtendedVias, dlg.nExtendedVias, dlg.pAddedNodes, dlg.nAddedNodes));
///以下为消息响应函数
void CViaExtending::OnUndo()
{
m_nCurUndo--;
memmove(m_bLayerFlags, m_cOriginal[m_nCurUndo], m_nMaxLayerIndex + 1);
LVITEM lvItem;
lvItem.mask = LVIF_IMAGE;
lvItem.iSubItem = 0;
for(int i = 0; i <= m_nMaxLayerIndex; i++)
{
lvItem.iItem = i;
lvItem.iImage = m_bLayerFlags[i];
m_List.SetItem(&lvItem);
}
m_cUndo[m_nCurUndo]->UndoObject(m_pView);
if(m_nCurUndo < 1)
m_Undo.EnableWindow(FALSE);
m_Redo.EnableWindow(TRUE);
}
当点击两次Undo按钮时程序Crash了!(具体如何操作就不说了)
原因是当点击第二次按钮时,使用了delete了的m_Undo类. 并且没有将它置空,就又使用了.里面涉及了野指针的内容.
- Access violation reading location 0x000000XX
- Access violation reading location 0x00000000
- Access violation reading location 0x00000000
- Access violation reading location 0xD15965C4
- 0xC0000005: Access violation reading location 0x00ef1000.
- Access violation reading location 0xccccccc0运行异常的解决方法
- Access violation reading location 0x00000000是什么错误呢?
- Access violation reading location 0xccccccc0运行异常的解决方法
- Unhandled exception at 0x00000000 in CallDll.exe: 0xC0000005: Access violation reading location 0x00
- Unhandled exception at 0x0133bc63 ....0xC0000005: Access violation reading location 0x00000004.
- Unhandled exception at 0x........ in XXXX.exe: 0xC0000005:Access violation reading location 0x......
- 关于出现Unhandled exception at 0x091f11c7 in ****: 0xC0000005: Access violation reading location 0x0ab0f
- Unhandled exception at 0x008f9b82 in .exe: 0xC0000005: Access violation reading location 0x00000298.
- itk 读图像 c++ 0xC0000005: Access violation reading location 0x00000000 出错总结
- opencv特征检测出现Unhandled exception at……Access violation reading location 0x00000000.
- Access violation reading at memory location xxx初探)
- 就会报Unhandled exception at 0x1000a0ce (Libnet.dll) in tcp1.exe: 0xC0000005: Access violation reading location 0xfffffe64.错误。 请问为什
- Crash Analyzing-- 0xC0000005: Access violation writing location 0x00000010
- 不要自称为程序员
- WTL 中CEdit如何设置一个tip,当用户没有输入任何东西的时候作为提示
- Sybase12.5影响内存分配的配置参数
- swfobject.embedSWF参数
- htaccess是什么
- Access violation reading location 0x000000XX
- VC 获取系统特殊文件夹的路径如:系统目录,桌面等
- 常用日期操作Calendar
- odbc oledb ado jdbc
- MD5加密方式
- 使用svn的过程中check out的文件路径中的文件图标全都加上了“蓝色问号”的解决方案
- 回顾ali历程
- 马士兵J2SE-第三章-面向对象-基础及重载
- Fedora16正式版发布