最近,我经常遇到类型错误
“未知模块中发生了‘System.StackOverflowException’类型的未处理异常。”。
这发生在具有相当大代码库(C#/XNA)的游戏(我开发的)中。但通常该错误仅在玩了几分钟的游戏后才会发生(而不是在每次运行中)。
问题是不幸的是,Visual Studio 调试器似乎无法进一步定位问题,只是让我检查汇编代码而不参考我的源代码行。如何调试这样的错误?我猜想 Valgrind 之类的工具在 C# 中不可用。是否有更好的调试器可以告诉我问题在源代码中的位置?
应用以下建议答案中的步骤时可用的调用堆栈。这是:
ntdll.dll!_NtWaitForSingleObject@12() + 0x15 bytes
ntdll.dll!_NtWaitForSingleObject@12() + 0x15 bytes
KernelBase.dll!_WaitForSingleObjectEx@12() + 0xcb bytes
kernel32.dll!_WaitForSingleObjectExImplementation@12() + 0x43 bytes
clr.dll!CLREvent::CreateManualEvent() - 0x15f3bb bytes
clr.dll!CLREvent::CreateManualEvent() - 0x15f37a bytes
clr.dll!CLREvent::WaitEx() + 0x47 bytes
clr.dll!CLREvent::Wait() + 0x19 bytes
clr.dll!Thread::WaitSuspendEventsHelper() + 0xa8 bytes
clr.dll!Thread::WaitSuspendEvents() + 0x17 bytes
clr.dll!Thread::RareEnablePreemptiveGC() + 0x181977 bytes
clr.dll!Thread::RareDisablePreemptiveGC() + 0x38e3 bytes
clr.dll!Debugger::SendException() + 0x12b bytes
clr.dll!Debugger::LastChanceManagedException() + 0x19f bytes
clr.dll!NotifyDebuggerLastChance() + 0x79 bytes
clr.dll!WatsonLastChance() + 0x166 bytes
clr.dll!EEPolicy::HandleFatalStackOverflow() + 0x189 bytes
clr.dll!EEPolicy::HandleStackOverflow() + 0xd8 bytes
clr.dll!_COMPlusFrameHandler() + 0xff302 bytes
ntdll.dll!ExecuteHandler2@20() + 0x26 bytes
ntdll.dll!ExecuteHandler@20() + 0x24 bytes
ntdll.dll!_RtlDispatchException@8() + 0xd3 bytes
ntdll.dll!_KiUserExceptionDispatcher@8() + 0xf bytes
clr.dll!SystemNative::ArrayCopy() + 0x19 bytes
mscorlib.ni.dll!6ed326a2()
Frames below may be incorrect and/or missing, no symbols loaded for mscorlib.ni.dll