简体   繁体   English

_BLOCK_TYPE_IS_VALID(pHead-> nBlockUse)在C ++中崩溃

[英]_BLOCK_TYPE_IS_VALID(pHead->nBlockUse) crash in C++

I have a Qt GUI program, inside it I could click a button to load/unload many dock widgets. 我有一个Qt GUI程序,在其中可以单击一个按钮来加载/卸载许多Dock小部件。 I have the problem that when I click the button to load/unload dock widgets, the programm crash with saying that 我有一个问题,当我单击按钮以加载/卸载扩展窗口小部件时,程序崩溃,并说

Debug Assertion Failed, Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)

It doesn't happen every time. 并非每次都发生。 (Actually very rare to happen.) And when I check the Windows's event log, it says the application hang with a cross thread dead lock. (实际上很少发生。)当我检查Windows的事件日志时,它说应用程序因交叉线程死锁而挂起。 But most people online said that the _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) means a memory error. 但是大多数在线人说_BLOCK_TYPE_IS_VALID(pHead-> nBlockUse)意味着内存错误。 I just don't what's going on... 我只是不知道发生了什么...

It is a very big program by someone else and the bug happens very rarely... What I could do now to locate the bug? 这是别人编写的非常大的程序,并且很少发生该错误...现在我该怎么做才能找到该错误?

EDIT: Hi, I have got the crash dump file, and I have seen that my program stop at a worker thread with the call stack: > ntdll.dll!_NtWaitForMultipleObjects@20() + 0x15 bytes 编辑:嗨,我有故障转储文件,并且我看到我的程序在调用堆栈的工作线程处停止:> ntdll.dll!_NtWaitForMultipleObjects@20()+ 0x15字节
How could I trace back to the source code that the program actually stop? 我如何追溯到程序实际停止的源代码?

That usually means you're trying to access an illegal memory block inside an std container. 这通常意味着您正在尝试访问std容器内的非法内存块。

To debug this properly, just look at the stack in the Call Stack window, look up the stack until you get to your code, and see why the value is invalid. 要正确调试它,只需在“ Call Stack窗口中查看Call Stack ,查找堆栈,直到获得代码,然后查看该值为何无效。

It's hard to describe it, but briefly, here is what you should do: 很难描述它,但是简单地说,这是您应该做的:

Install Application Verifier and run it. 安装应用程序验证程序并运行它。

Ctrl+A , select your executable. Ctrl + A ,选择您的可执行文件。

Deselect all tests in the right pane, select only Basic->Heaps. 取消选择右窗格中的所有测试,仅选择“基本”->“堆”。

Ensure you have 'Full heap' enabled and 'Traces' enabled (properties via right click on 'Heaps' item). 确保已启用“全堆”和“跟踪”(通过右键单击“堆”项的属性)。

Save. 救。 You may close Application Verifier now. 您可以立即关闭Application Verifier。

Launch WinDBG of proper architecture (the same as your app). 启动具有适当架构的WinDBG(与您的应用程序相同)。

Ctrl+E , select your executable. Ctrl + E ,选择您的可执行文件。

The program will be stopped on first instruction, run it using F5 该程序将在第一条指令上停止,使用F5运行

The probability you'll hit the bug will be much higher. 您遇到该错误的可能性会更高。 You'll also may found memory access issue you were not aware of before. 您可能还会发现以前没有意识到的内存访问问题。 When you hit one of them, the debugger will stop with one of 'Verifier stops' and you'll see the message in console telling you which command you can use to investigate further. 当您击中其中一个时,调试器将以“验证器停止”之一停止,您将在控制台中看到该消息,告诉您可以使用哪个命令进行进一步调查。 Usually you'll be able to see detailed info about the heap using !heap -p -a <address> , including allocation and deallocation stacks. 通常,您可以使用!heap -p -a <address>来查看有关堆的详细信息,包括分配和释放堆栈。

Remember, that Application Verifier checks are enabled even when Application Verifier application is not started. 请记住,即使未启动Application Verifier应用程序,也将启用Application Verifier检查。 You need to run Application Verifier, disable the checks and press 'Save' to actually disable them. 您需要运行Application Verifier,禁用检查,然后按“保存”以实际禁用它们。

Hope this will help, at least a bit. 希望这至少可以有所帮助。 Read more about Application Verifier techniques on the Internet. 在Internet上阅读有关Application Verifier技术的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 _BLOCK_TYPE_IS_VALID(pHead-&gt; nBlockUse)C ++文件 - _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) C++ FILE 解决“ _BLOCK_TYPE_IS_VALID(pHead-&gt; nBlockUse)”崩溃。 C ++ - Solving the “_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)” crash. C++ 使用ASSERT调整动态分配的内存C ++的大小“ _BLOCK_TYPE_IS_VALID(pHead-&gt; nBlockUse)” - resize dynamically allocated memory C++ with ASSERT“ _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) ” c ++ Qt表达式:_BLOCK_TYPE_IS_VALID(pHead-&gt; nBlockUse)错误 - c++ Qt Expression : _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) error _block_type_is_valid(phead-nblockuse)由于删除命令 - _block_type_is_valid(phead- nblockuse) because of delete command 表达式_BLOCK_TYPE_IS_VALID(pHead-&gt; nBlockUse)错误 - Expression _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) Error 错误-_BLOCK_TYPE_IS_VALID(pHead-&gt; nBlockUse) - Error - _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) 调试断言失败_BLOCK_TYPE_IS_VALID(pHead-&gt; nBlockUse) - Debug Assertion Failed _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) “返回0”后__BLOCK_TYPE_IS_VALID(pHead-&gt; nBlockUse) - _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) after “return 0” 调试断言失败... _BLOCK_TYPE_IS_VALID(pHead-&gt; nBlockUse) - Debug Assertion Failed … _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM