有没有Valgrind Memcheck像Windows的工具,调试使用后的免费错误? [英] Is there Valgrind Memcheck like tool for windows to debug use after free errors?

查看:236
本文介绍了有没有Valgrind Memcheck像Windows的工具,调试使用后的免费错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

杜林我的工作我的表面面对相当普遍的编程错误 - 使用一些已经被释放的对象。这在C ++中调用UB。在 linux 上,这种问题通常使用Valgrind工具Memcheck解决。从 Memcheck手册


Memcheck尝试确定非法地址可能涉及的内容,
,因为这通常很有用。所以,如果它指向一个已经被释放的内存块
,那么你会被通知这个,还有
这个块被释放了。


< blockquote>

Memcheck提供了调用堆栈,其中对象被释放,我可以继续调试问题。

解决方案

根据博士的说法,具有相同功能的窗口有类似的工具内存文档中有 -delay_frees_stack 选项与Valgrind功能完全相同。从选项参考

  -delay_frees_stack 
默认值:false
在报告使用自由或与释放的对象重叠的其他错误时,可以自由使用记录调用堆栈。对于malloc密集型应用程序,此功能产生轻微的性能影响。

此处还有一个 Dr.内存记录报告:

 这是另一个例子,使用-delay_frees_stack选项来获取释放的内存的调用堆栈:

错误#8:UNADDRESSABLE ACCESS:读取0x001338a8-0x001338ac 4个字节
#0 unaddr_test1 [e:\ derek\drmemory\git\src\tests\suppress.c:110]
#1 test [e:\derek\drmemory\git\src\tests\suppress。 c:269]
#2 main [e:\derek\drmemory\git\src\tests\suppress.c:297]
注意:@ 0:00:02.141 in线程3024
注意:下一个更高的malloc:0x001338e8-0x00133938
注意:prev lower malloc:0x001337e8-0x00133820
注意:0x001338a8-0x001338ac重叠内存0x001338a8-0x001338c4,这里释放:
注意:#0测试[e:\derek\drmemory\git\src\tests\suppress.c:269]
注意:#1 main [e:\derek\drmemory\git\src \tests\suppress.c:297]
注意:说明:mov(%eax) - > %eax


Durring my work I regulary face rather common programming error - using some object which has already been freed. This invokes UB in C++. On linux, this kind of problems are usually resolved by using Valgrind tool Memcheck. From Memcheck manual:

Memcheck tries to establish what the illegal address might relate to, since that's often useful. So, if it points into a block of memory which has already been freed, you'll be informed of this, and also where the block was freed.

Memcheck provides me call stack, where the object was deallocated and I can go on and debug the problem. Is there similar tool for windows with the same functionality, preferably free?

解决方案

According to Dr. Memory documentation, there is -delay_frees_stack option with exactly the same Valgrind functionality. From Option Reference:

-delay_frees_stack 
default: false 
Record callstacks on free to use when reporting use-after-free or other errors that overlap with freed objects. There is a slight performance hit incurred by this feature for malloc-intensive applications.

Also here is an example of error reported by Dr. Memory:

Here is another example, using the -delay_frees_stack option to obtain the callstack of the freed memory:

Error #8: UNADDRESSABLE ACCESS: reading 0x001338a8-0x001338ac 4 byte(s)
# 0 unaddr_test1                    [e:\derek\drmemory\git\src\tests\suppress.c:110]
# 1 test                            [e:\derek\drmemory\git\src\tests\suppress.c:269]
# 2 main                            [e:\derek\drmemory\git\src\tests\suppress.c:297]
Note: @0:00:02.141 in thread 3024
Note: next higher malloc: 0x001338e8-0x00133938
Note: prev lower malloc:  0x001337e8-0x00133820
Note: 0x001338a8-0x001338ac overlaps memory 0x001338a8-0x001338c4 that was freed here:
Note: # 0 test                            [e:\derek\drmemory\git\src\tests\suppress.c:269]
Note: # 1 main                            [e:\derek\drmemory\git\src\tests\suppress.c:297]
Note: instruction: mov    (%eax) -> %eax

这篇关于有没有Valgrind Memcheck像Windows的工具,调试使用后的免费错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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