Visual Studio - 如何找到堆损坏错误的来源 [英] Visual Studio - how to find source of heap corruption errors

查看:20
本文介绍了Visual Studio - 如何找到堆损坏错误的来源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

鉴于在 Visual Studio 中分配的堆块外部"写入的数据的内存地址,我想知道是否有一种好方法可以找到导致堆损坏错误的源代码;

I wonder if there is a good way to find the source code that causes a heap corruption error, given the memory address of the data that was written 'outside' the allocated heap block in Visual Studio;

专用 (0008) 空闲列表元素 26F7F670 大小错误(死)

Dedicated (0008) free list element 26F7F670 is wrong size (dead)

(尝试写一些关于如何查找内存错误的笔记)

(Trying to write down some notes on how to find memory errors)

推荐答案

从安装windbg开始:

Begin with installing windbg:

http://www.microsoft.com/whdc/Devtools/Debugging/default.mspx

然后像这样打开pageheap:

Then turn on the pageheap like this:

gflags.exe /p /enable yourexecutable.exe /full

这将在每次堆分配后插入一个不可写的页面.

This will insert a non writable page after each heap allocation.

从windbg内部启动可执行文件后,堆外的任何写入现在都将被此调试器捕获.之后要关闭页面堆,请使用:

After this launch the executable from inside windbg, any writes outside the heap will now be caught by this debugger. To turn of the pageheap afterwards use this:

gflags.exe /p /disable yourexecutable.exe

有关如何使用 pageheap 的更多信息此处.

More info on how to use the pageheap here.

这篇关于Visual Studio - 如何找到堆损坏错误的来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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