如何修复由于堆损坏而导致的错误

how to fix bug due to a heap corruption

本文关键字:错误 损坏 何修复 于堆      更新时间:2023-10-16

当我的应用程序崩溃时,我有以下调用堆栈(通过MSVC210保存转储功能和winbdg在第二次使用k命令创建):

0012c720 7d684c89 0012c93c 7d656a16 063acab8 ntdll!DbgBreakPoint
0012c728 7d656a16 063acab8 0000035c 035f0000 ntdll!RtlpBreakPointHeap+0x28
0012c93c 7d685892 035f0000 50000161 0000035c ntdll!RtlAllocateHeapSlowly+0x231
0012c9b0 7d65695e 035f0000 50000161 0000035c ntdll!RtlDebugAllocateHeap+0xaf
0012cbcc 7d62ba89 035f0000 40000060 0000035c ntdll!RtlAllocateHeapSlowly+0x41
0012cdfc 10308343 035f0000 40000060 0000035c ntdll!RtlAllocateHeap+0xe9f
0012ce14 1031697c 0000035c c8fa7bd5 0012deb0 MSVCR100D!_heap_alloc_base+0x53
0012ce5c 1031671f 00000338 00000001 00000000 MSVCR100D!_nh_malloc_dbg+0x2dc
0012ce7c 103166cc 00000338 00000000 00000001 MSVCR100D!_nh_malloc_dbg+0x7f
0012cea4 10319c5b 00000338 00000000 00000001 MSVCR100D!_nh_malloc_dbg+0x2c
0012cec4 10307db1 00000338 04f26388 0012cfac MSVCR100D!malloc+0x1b
0012cee0 65302a58 00000338 c8876569 00000070 MSVCR100D!operator new+0x11

这似乎是由于堆损坏。

我不知道如何或什么寻找在我的代码修复错误..

有没有最好的方法来修复这个bug ?

Thanks to lot

堆损坏可能是由于许多原因造成的,很难通过代码分析来检测这样的代码。最好的方法是:

通过ValgrindRational Purifyplus或任何此类内存分析工具运行您的代码,它们将帮助您确定确切的错误并将其指出给您。

看一下:
如何调试堆损坏错误?