调试 Visual C++ 内存分配问题

发布于 2024-07-17 04:12:18 字数 1184 浏览 9 评论 0原文

我正在调试一个软件,该软件最终崩溃并显示以下消息之一:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱已欠费 2024-07-24 04:12:18

您可以通过附加到 Windbg 以发布模式运行应用程序。

  • 启用 gflags (当您
    提到)
  • 在发布中启动应用程序
    模式。
  • 使用 Attach to 将其附加到 Windbg
    Windbg 中的 process 选项。
  • 配置正确的路径
    释放 PDB。
  • 使用手动重新加载 PDB
    .reload /f 如果是自动的
    加载失败。
  • 执行用例。

每当发生异常时WinDbg就会停止执行。 对于每一个第一次机会异常,分析原因。 这可能是崩溃的错误之一。

You can run your application in release mode by attaching to Windbg.

  • Enable the gflags ( As you
    mentioned)
  • Start the application in release
    mode.
  • Attach it to Windbg using Attach to
    process
    option in Windbg.
  • Configure the correct path for
    release PDBs.
  • Reload the PDB manually using
    .reload /f in case of automatic
    loading fails.
  • Perform the use case.

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.

享受孤独 2024-07-24 04:12:18

在使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文