“Debug Assertion” Runtime Error on VS2008 VS2010 winhand.cpp
I'm writing a C++ MFC program on VS2008 and I'm getting this "Debug Assertion Error" when I first run the program sometimes. When I try to debug it, it takes me to this winhand.cpp file which is not part of the program I wrote so I'm not sure how to debug this.
It takes the error to this place in winhand.cpp
CObject* pTemp = LookupTemporary(h);
if (pTemp != NULL)
{
// temporary objects must have correct handle values
HANDLE* ph = (HANDLE*)((BYTE*)pTemp + m_nOffset); // after CObject
ASSERT(ph[0] == h || ph[0] == NULL);
if (m_nHandles == 2)
ASSERT(ph[1] == h);
}
So why does this error happen? Why does it only happen sometimes (50% of the time)? How would I debug this?
I'll provide some code if is needed.
THANKS!
Answers
The code that is asserting is part of MFC's CHandleMap class. MFC deals with windows as CWndobjects, but Windows deals with them as HWND handles. the handle map allows MFC to 'convert' anHWND into a pointer to the MFC object representing that object.
What the assertion seems to be doing is checking that when a lookup of the handle finds an MFC object, that the MFC object also thinks it's wrapping the same handle.
If they're different, then you get the assertion.
So it would appear that something is corrupting the handle map or the MFC object for that handle or you're doing something incorrect that gets these 2 data structures out of sync.
Some things you might do to try to debug the problem is to determine:
- what MFC object is being found in the lookup (that's what's being pointed to by
pObject) - what the MFC object thinks it's wrapping (that's the handle
ph[0]and/orph[1]- I'm not sure why there can be 2 of them) - what the handle is for (that's
h)
Do the handles look like handle values or do they look like garbage? Does pObject point to something that looks like an MFC object, or garbage? Do any of these these things seem related?
The answers to these questions may point to what you need to do next (maybe set a debug write breakpoint on the item that looks like it's trashed).
我在coding的时候也遇到这个问题了,后来找到了出错语句:
((COutPutDlg*)GetParent())->m_CurIndex=m_CurIndex;
上面语句所在的类CPreviewDlg的对象窗体本来处于类COutPutDlg对象窗体之上,即前者是后者的子窗体,后来我使用语句:
SetParent(GetDesktopWindow());
该语句改变了CPreviewDlg对象的父窗体,改变后,调用((COutPutDlg*)GetParent())->m_CurIndex=m_CurIndex;并不会报错,但是在程序退出的时候,就出现了“Debug Assertion” Runtime Error。
原因好像就是上文中说的对应关系被破坏了,不是很了解,还有其他事,暂且放一放。
“Debug Assertion” Runtime Error on VS2008 VS2010 winhand.cpp的更多相关文章
- Solve Error Debug Assertion Failed Expression vector iterators incompatible Using PCL in Release Mode of VS2010
When using PCL 1.4.0 in the release mode building under VS2010, we might sometime get the error &quo ...
- C++ error:Debug Assertion Failed.Expression:_BLOCK_TYPE_IS_VALID(phead->nBlock)
Debug Assertion Failed.Expression:_BLOCK_TYPE_IS_VALID(phead->nBlockUse) 关于上面这个错误,我在上一篇文章中的程序遇到过了 ...
- Qt Sqlite qwt 发布过程中碰到的问题runtime error
qt版本:4.8.0 qwt版本:6.1.2 使用dll show检测缺少的dll,或者笨一点的方法,点击运行差什么找什么放进去: 左上显示exe调用哪些dll,右边是dll又再次调用啦哪些dll: ...
- Qt 调试时的错误——Debug Assertion Failed!
在VS2008中写qt程序时调试出现此问题,但在release模式下就不存在,在网上搜罗了一圈,是指针的问题. 问题是这样的: 需要打开两个文件,文件中数据类型是float,我使用QVector进行保 ...
- Microsoft Visual C++ Runtime Library Runtime Error的解决的方法
打开浏览器时,出现Microsoft Visual C++ Runtime Library Runtime Error错误,初步预计是软件冲突,可能有多种出错的方式,我的是浏览器自己主动关闭. 一. ...
- Microsoft Visual C++ Runtime Library Runtime Error解决的方式
打开浏览器时,出现Microsoft Visual C++ Runtime Library Runtime Error错误,初步预计是软件冲突,可能有多种出错的方式,我的是浏览器自己主动关闭. 一. ...
- C Run-Time Error R6034问题的解决
1.问题描述 这两天一直在用vs2008编写一个小项目,需要在c++代码中通过命令行的方式调用cl.exe和link.exe,也就是给编译器cl和链接器link传递参数,然后编译链接生成可执行文件ex ...
- opencv 3.2 vs2015 debug assertion __acrt_first_block == header
网上复制了一个转直方图的代码 ,说来也奇怪, 用imshow 显示 图片在独立窗体内,不存在问题, 要注释掉这段代码就出现了下边的错误. 网上查了查,原来是程序中 有个std::vector<c ...
- Runtime Error R6034 Application has attempt to load the C runtime library incorrectly
1.问题描述 vs2015 去开发一个写入pg数据库的程序,使用libpqxx.dll,libpq.dll,这个库文件之前是用vs2008的程序中复制过来的,基于的运行时库应该是vs2008,现在开发 ...
随机推荐
- Tomcat 安装之后,双击Tomcat.exe,无法运行成功,怎么办?
Log形式多种多样,有的时候跟下面一样: 首先的解决方案就是:修改server.xml中所有的端口,因为不只8080端口可能被占用! 我在出问题的时候就修改8080端口.结果死活运行不了,纠结一些时间 ...
- Spring Boot配置多个DataSource
使用Spring Boot时,默认情况下,配置DataSource非常容易.Spring Boot会自动为我们配置好一个DataSource. 百牛信息技术bainiu.ltd整理发布于博客园 如果在 ...
- FFmpeg+FFserver流媒体服务器介绍
ffmpeg和ffserver配合使用可以实现实时的流媒体服务. 一.理解 里边主要有如下四个东西,搞清楚他们之间的关系就差不多明白了. 1. ffmpeg 2. ffserver 3. ...
- Nagios监控Windows的网卡流量
Nagios监控Windows的网卡流量 使用/usr/local/nagios/libexec/中的check_traffic.sh,不但可以监控Linux的网卡流量,也可以监控Windows服务器 ...
- 【旧文章搬运】PsVoid中IrpCreateFile函数在Win7下蓝屏BUG分析及解决
原文发表于百度空间,2010-04-05========================================================================== 这也许是我 ...
- sqlserver 截取字符串
**/*******/*****/1399/* 我要取第3个'/'与第4个'/'中的内容,就是1399 create table ta( col varchar(100)) insert ta sel ...
- spown mj
local function getmjvalnew(key) local keynew = {} local sumnval = 0 for _, v in ipairs(key) do if v& ...
- HDU 3729【二分匹配】
题意: 给出n个同学的排名,代表每个排名在哪个区间,要求保证最多人说的是实话,并在此前提下求一个说真话人最大字典序. 思路: 最后感觉就是点去填区间,点和区间建个边,然后跑个二分图,然后sort一发. ...
- 洛谷P3321 [SDOI2015]序列统计(NTT)
传送门 题意:$a_i\in S$,求$\prod_{i=1}^na_i\equiv x\pmod{m}$的方案数 这题目太珂怕了……数学渣渣有点害怕……kelin大佬TQL 设$f[i][j]$表示 ...
- [Xcode 实际操作]八、网络与多线程-(24)社会化分享功能开发包的安装和配置:微信、QQ、微博
目录:[Swift]Xcode实际操作 本文将演示如何在开放平台注册应用,并获得相关的密钥信息,用于实现后面文章的微博分享功能. 一.新浪微博开放平台 [登录]->[微服务]->[粉丝服务 ...