调试 Visual C++ 内存分配问题
我正在调试一个软件,该软件最终崩溃并显示以下消息之一:
1. DAMAGE: after normal block (#24729280) at 0x00D710E0
2. Debug Assertion Failed
Program: D:\Soft\Test.exe
File: dbgheap.c
Line: 1017
Expression: _BLOCK_TYPE_IS_VALID(phead->nBlockUse)
该软件确实很旧,但现在无法更改它。 它是在 Visual C++ 6.0 上编写的。 我们猜测这是某种缓冲区溢出,因此我们正在尝试找到方法来检测它发生的位置。
我找到了有关 PageHeap 的信息(它似乎能够告诉我我想要什么) 和 GFlags,但是看来我无法让它发挥作用。
我创建了一个测试程序:
char* test;
test = new char[5];
test[5] = 'a';
delete[] test;
引发了一个错误:
DAMAGE: after normal block (#55) at 0x1671920
然后,我尝试通过运行: 将 PageHeap 附加到它,
gflags.exe /p /enable MemoryTest.exe /full
然后重新运行它(通过 Visual C++ 6.0 界面和 Windows 资源管理器),这导致了相同的错误。
然后我尝试编译发行版本,并通过 Visual C++ 6.0 界面运行它以获取错误:
User breakpoint called from code at 0x7c90120e
从 Windows 资源管理器中,我刚刚收到 Windows 对话框,要求我发送错误报告。
我缺少什么?
I'm debugging a software which crashes eventually with one of the following messages:
1. DAMAGE: after normal block (#24729280) at 0x00D710E0
2. Debug Assertion Failed
Program: D:\Soft\Test.exe
File: dbgheap.c
Line: 1017
Expression: _BLOCK_TYPE_IS_VALID(phead->nBlockUse)
This software is really old but changing it now is not an option. It's written on Visual C++ 6.0. We are guessing it's some kind of buffer overflow, so we are trying to find ways to detect where it is happening.
I have found information about PageHeap (which seems to be able to tell me what I want) and GFlags, but it seems I can't make it work.
I created a test program:
char* test;
test = new char[5];
test[5] = 'a';
delete[] test;
which raises an error:
DAMAGE: after normal block (#55) at 0x1671920
Then, I tried attaching PageHeap to it by running:
gflags.exe /p /enable MemoryTest.exe /full
and then rerunning it (both through Visual C++ 6.0 interface and through the windows explorer), which resulted on the same error.
Then I tried to compile the release version, and ran it through the Visual C++ 6.0 interface to get the error:
User breakpoint called from code at 0x7c90120e
And from the windows explorer, I just got the windows dialog asking me to send an error report.
What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过附加到 Windbg 以发布模式运行应用程序。
gflags
(当您提到)
模式。
Attach to 将其附加到 Windbg
Windbg 中的 process 选项。
释放 PDB。
.reload /f
如果是自动的加载失败。
每当发生异常时WinDbg就会停止执行。 对于每一个第一次机会异常,分析原因。 这可能是崩溃的错误之一。
You can run your application in release mode by attaching to Windbg.
gflags
( As youmentioned)
mode.
Attach to
option in Windbg.process
release PDBs.
.reload /f
in case of automaticloading fails.
WinDbg would stop the execution whenever an exception occurs. For every first chance exception, analyze the reasons. It could be one of the error for crash.
在使用 gFlags/PageHeap 之前,我建议您检查访问冲突异常。 首先使用“构建”->“开始调试”->“附加到进程”选项来附加进程。 连接后,通过转到“调试”->“异常”选择“访问冲突”并选中“始终停止”复选框来启用访问冲突异常。 然后检查您的调试器是否捕获任何访问冲突异常。
Before using gFlags/PageHeap I suggest you to check for Access Violation exception. First attach the process by using Build->Start Debug->Attach to process option. Once it is attached enable the access violation exception by going to Debug->Exceptions select Access Violation and select the check box Stop Always. Then check whether your debugger catches any access violation exceptions.