I have a .NET application, which is using an open source C++ compression library for compressing images. We are accessing the C++ library via managed C++. I'm seeing heap corruption during compression. A call to _CrtIsValidHeapPointer is finding an error on a call to free() when cleaning up after compression.
我有一个.NET应用程序,它使用开源C ++压缩库来压缩图像。我们通过托管C ++访问C ++库。我在压缩期间看到堆损坏。对_CrtIsValidHeapPointer的调用是在压缩后清理时调用free()时发现错误。
My question is, are there tools such as Purify to help diagnosis this problem and what is causing the heap corruption when working in a combination of managed and unmanaged code? I do have the exception caught in the debugger, but it would be nice to have other tools to help find the solution to the problem.
我的问题是,是否有像Purify这样的工具来帮助诊断这个问题,以及在托管代码和非托管代码的组合中导致堆损坏的原因是什么?我确实在调试器中捕获了异常,但是有其他工具来帮助找到问题的解决方案会很好。
3 个解决方案
#1
1
In native code, if the corruption always occurs in the same place in memory, you can use a data breakpoint to break the debugger when that memory is changed. Unfortunately, you cannot set a data breakpoint in the managed C++ environment, presumably because the GC could move the object in memory.
在本机代码中,如果损坏始终发生在内存中的相同位置,则可以在更改内存时使用数据断点来中断调试器。遗憾的是,您无法在托管C ++环境中设置数据断点,可能是因为GC可能会将对象移动到内存中。
Not sure if this helps, but hopefully it leads you off in the right direction.
不确定这是否有帮助,但希望它能引导你走向正确的方向。
#2
1
on *nix, there's a tool called valgrind that I use for dealing with memory issues, like memory leaks and memory corruption.
在* nix上,有一个名为valgrind的工具,我用它来处理内存泄漏和内存损坏等内存问题。
#3
0
Rational Purify for Windows supports .NET, so I guess that could be used?
Rational Purify for Windows支持.NET,所以我想可以使用它?
#1
1
In native code, if the corruption always occurs in the same place in memory, you can use a data breakpoint to break the debugger when that memory is changed. Unfortunately, you cannot set a data breakpoint in the managed C++ environment, presumably because the GC could move the object in memory.
在本机代码中,如果损坏始终发生在内存中的相同位置,则可以在更改内存时使用数据断点来中断调试器。遗憾的是,您无法在托管C ++环境中设置数据断点,可能是因为GC可能会将对象移动到内存中。
Not sure if this helps, but hopefully it leads you off in the right direction.
不确定这是否有帮助,但希望它能引导你走向正确的方向。
#2
1
on *nix, there's a tool called valgrind that I use for dealing with memory issues, like memory leaks and memory corruption.
在* nix上,有一个名为valgrind的工具,我用它来处理内存泄漏和内存损坏等内存问题。
#3
0
Rational Purify for Windows supports .NET, so I guess that could be used?
Rational Purify for Windows支持.NET,所以我想可以使用它?