Recently, I am regularly encountering errors of type
"An unhandled exception of type 'System.StackOverflowException' occurred in Unknown Module.".
This happens in a game (that I developed) with a quite large code base (C# / XNA). But typically the error occurs only after several minutes of gameplay (and not in every run).
The problem is that unfortunately, the Visual Studio debugger seems to not be able to further localize the problem and just lets me inspect the assembler code without reference to my source lines. How could one debug such an error? I guess tools like Valgrind are not available in C#. Is there maybe a better debugger that can show me where the problem is localized in the source code?
The call stack available when applying the steps in the suggested answer below. It is:
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
If the crash is happening with ntdll.dll, you'd need the symbols for it, but I think the more likely possibility is that you are passing some weird junk in that is causing it to crash. Are you making an Windows API calls that might be crashing it?
Another possibility, which was mentioned by another user here is that you could be making a recursive call somewhere that is running out the stack. This would be especially problematic if the calls are being made to unmanaged pieces of code:
Also, a couple of things you may want to try before you go down the road for looking for an alternative way to debug:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With