请求的帮助:“调试断言失败"进程挂起 [英] Help requested: "Debug assert failed" with process hang

查看:155
本文介绍了请求的帮助:“调试断言失败"进程挂起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,
我是C ++的新手,我已经编写了一个基本项目,只是为了玩转模板.它由以下类组成:

-枚举(与.NEt Framework代码中的IEnumerable十分相似)
-list< Type> [来自可枚举的继承](提供基本的添加和删除以及初始大小).

-keyValuePair< KeyType,ValueType> (是具有2个属性的简单结构-键和值...

-字典< KeyType,ValueType> [继承自列表](是一个使用keyValuePair

的列表,不会出现错误直到我的程序执行结束为​​止,这时该程序只是在执行我的最终指令时挂起:

delete [] pDict;

我的程序当前执行的操作并不比添加复杂.字典中有一些初始项,检索到一个填充有键的列表对象,然后清理...因此我暂停了调试器,它警告我:

该进程似乎已死锁(或未运行任何进程)用户模式代码).所有线程均已停止.

然后将我指向:

dbgrpt.c(第360-363行):
<pre> /* Report the warning/error */<br /> nCode = __crtMessageBox(szOutMessage,<br /> _T("Microsoft Visual C++ Debug Library"),<br /> MB_TASKMODAL|MB_ICONHAND|MB_ABORTRETRYIGNORE|MB_SETFOREGROUND);</pre>

并指出包含_T("Mi ...的行是发生错误的地方.据我所知," dbgprt.c文件的这一部分显示了断言失败的错误消息.帮助任何人:

<pre> szOutMessage = "Debug Assertion Failed!<br /> Program: ...iversity for the West of Scotland\Samples\Debug\Templates.exe<br /> File: f:\dd\vctools\crt_bld\self_x86\crt\src\dbgdel.cppLine: 52<br /> Expression: _BLOCK_TYPE_IS_VALID(pHead-&gt;nBlockUse)<br /> For information on how your program can cause an assertion<br /> failure, see the Visual C++ documentation on asserts.<br /> (Press Retry to debug the application)";</pre>

然后我就出海了rch MSDN文档,发现没有什么可以帮助我...不幸的是,对该论坛的搜索没有帮助我进一步发展,所以这是我的问题:

我应该在哪里看?我应该寻找什么可能的错误源?

我已经检查了未初始化的变量,内存泄漏,并确保(我认为)所有返回值的函数都有一个变量来复制到其中以便清理堆栈...到目前为止,一切似乎还不错.

谢谢您的阅读.

Hi there,
I''m new to C++ and i''ve got a basic project i''ve made up, just to play around with templates. It consists of the following classes:

- enumerable (used much like IEnumerable in .NEt Framework code)
- list<Type> [inherits from enumerable] (provides basic add & remove alongside initial sizes)

- keyValuePair<KeyType, ValueType> (is a simple struct with 2 properties - key and value...

- dictionary<KeyType, ValueType> [inherits from list] (is a list, which uses keyValuePair

No error appears to occur until the end of my program exection. At this point the program simply hangs while executing my final instruction:

delete [] pDict;

My program currently does something no more complex than adding a few initial items to a dictionary, retrieving a list object filled with keys and then cleaning up... So I pause the debugger, it warns me:

The process appears to be deadlocked (or is not running any user-mode code). All threads have been stopped.

and it then points me to:

dbgrpt.c (line 360 - 363):
<pre> /* Report the warning/error */<br /> nCode = __crtMessageBox(szOutMessage,<br /> _T("Microsoft Visual C++ Debug Library"),<br /> MB_TASKMODAL|MB_ICONHAND|MB_ABORTRETRYIGNORE|MB_SETFOREGROUND);</pre>

and points out that the line containing _T("Mi... is where the error occured. As far as i can understand, this portion of the "dbgprt.c" file displays an assertion failed error message. In case that helps any:

<pre> szOutMessage = "Debug Assertion Failed!<br /> Program: ...iversity for the West of Scotland\Samples\Debug\Templates.exe<br /> File: f:\dd\vctools\crt_bld\self_x86\crt\src\dbgdel.cppLine: 52<br /> Expression: _BLOCK_TYPE_IS_VALID(pHead-&gt;nBlockUse)<br /> For information on how your program can cause an assertion<br /> failure, see the Visual C++ documentation on asserts.<br /> (Press Retry to debug the application)";</pre>

I then proceded to search MSDN documentation and found nothing specific to help me... Unfortunately searches of this forum didn''t help me get any further so here is my question:

Where should I look? and what should I be looking for as possible sources of the error?

I''ve checked for un-initialised variables, memory leaks, and ensured (i think) all functions that return a value have a variable to be copied into so as to clean the stack... and so far all seems fine.

Thankyou for reading.

推荐答案

第一个问题:是pDict分配为数组,即
First question: Was pDict allocated as an array, i.e.
pDict = new pDictType[size];

您正在使用数组删除语法(delete []pDict).如果pDict是一个简单的指针,那么使用数组删除将做坏事.除此之外,我建议的一般情况是逐步遍历代码并确保您不走步在堆栈中的某物上.您描述的症状(退出所有线程)听起来像是堆栈被覆盖.

You are using the array delete syntax (delete []pDict). If pDict is a simple pointer, then using the array delete will Do Bad Things.

Other than that, the general things I can suggest are to step through the code and ensure that you''re not walking over something in the stack. The symptom you are describing (all threads exited) sounds like a stack overwrite.


这篇关于请求的帮助:“调试断言失败"进程挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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