调试Visual C ++内存分配问题 [英] Debug Visual C++ memory allocation problems

查看:183
本文介绍了调试Visual C ++内存分配问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在调试一个最终会因以下消息之一而崩溃的软件:

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)

该软件确实很旧,但现在不能更改.它是在Visual C ++ 6.0上编写的.我们猜测这是某种缓冲区溢出,因此我们试图找到方法来检测它的发生位置.

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.

我找到了有关 PageHeap 的信息(似乎可以告诉我我想要的)和 GFlags ,但看来我无法使其正常工作.

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;

这会引发错误:

DAMAGE: after normal block (#55) at 0x1671920

然后,我尝试通过运行以下命令将PageHeap附加到它:

Then, I tried attaching PageHeap to it by running:

gflags.exe /p /enable MemoryTest.exe /full

,然后重新运行它(通过Visual C ++ 6.0界面和Windows资源管理器),导致相同的错误.

and then rerunning it (both through Visual C++ 6.0 interface and through the windows explorer), which resulted on the same error.

然后我尝试编译发行版本,并通过Visual C ++ 6.0界面运行它以获取错误:

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

然后从Windows资源管理器中,我得到了Windows对话框,要求我发送错误报告.

And from the windows explorer, I just got the windows dialog asking me to send an error report.

我想念什么?

推荐答案

您可以通过附加到

  • 启用gflags 提到)
  • 启动发布中的应用程序 模式.
  • 使用Windbg中的Attach to process选项将其附加到Windbg.
  • 配置正确的路径 发布PDB.
  • 使用以下命令手动重新加载PDB .reload /f在自动情况下 加载失败.
  • 执行用例.
    • 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就会停止执行.对于每个第一次机会异常,请分析原因.这可能是崩溃的错误之一.

    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.

    这篇关于调试Visual C ++内存分配问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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