Tag: heap corruption

如何调试托管堆中的损坏

我的程序抛出一个错误,它无法通过catch(Exception e)块处理,然后崩溃: 访问冲突损坏的状态exception。 这是奇怪的事情,因为,正如我所知,从非托管代码抛出损坏的状态exception,而在这里我在调用StringBuilder方法时得到此exception。 代码在后台线程中运行并且不时崩溃,这是不容易再现的。 所以我将WinDbg附加到进程并具有以下exception堆栈: 000000001dabd8c8 000007feea129a1d [HelperMethodFrame: 000000001dabd8c8] 000000001dabda00 000007fee90cfce8 System.Text.StringBuilder.ExpandByABlock(Int32) 000000001dabda40 000007fee90cfba4 System.Text.StringBuilder.Append(Char*, Int32) 000000001dabdaa0 000007fee9102955 System.Text.StringBuilder.Append(System.String, Int32, Int32) 000000001dabdaf0 000007ff00bf5ce3 MineUtils.Common.Strings.Strings.Replace(System.String, System.String, System.String, Boolean, Boolean) 000000001dabdb90 000007ff00bf5a59 MineUtils.Common.Strings.Strings.RemoveSubstrings(System.String, System.String, System.String, Boolean) [D:\Programs\Visual Studio 2005 Projects\MineUtils.Common\Strings\Strings.Common-Main.cs @ 1481 WinDbg显示发生此exception: EXCEPTION_RECORD: ffffffffffffffff — (.exr 0xffffffffffffffff) ExceptionAddress: 000007feea129a1d (clr!WKS::gc_heap::find_first_object+0x0000000000000092) ExceptionCode: c0000005 (Access violation) ExceptionFlags: […]