问题描述
Durring我的工作我regulary面临相当普遍的编程错误 - 使用一些已经被释放的对象。这在C ++中调用UB。在 linux ,这种问题通常通过使用Valgrind工具Memcheck来解决。从:
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提供了我调用堆栈,对象被释放,我可以继续和调试问题。是否有类似工具 Windows 具有相同的功能,最好是免费的?
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?
推荐答案
内存文档,有具有完全相同的Valgrind功能的 -delay_frees_stack
选项。从:
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.
此处还有一个示例:
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调试使用后的免费错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!