How to debug System.StackOverflowException without link to source code?

后端 未结 2 1095
陌清茗
陌清茗 2021-01-18 04:10

Recently, I am regularly encountering errors of type

\"An unhandled exception of type \'System.StackOverflowException\' occurred in Unknown Module.

相关标签:
2条回答
  • 2021-01-18 04:19

    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:

    • Are there any logic conditions that might cause an infinite loop?
    • Are there any constructors that make unintentional recursive calls?
    • Are there any recursive methods in your code that might be stuck?

    Also, a couple of things you may want to try before you go down the road for looking for an alternative way to debug:

    1. Ensure that the project is built in debug
    2. Check Visual Studio settings to be sure that it is halting on all exceptions
    3. Turn off the "just my code" setting if it is available in your project settings (does this even show up in C# projects?)
    4. Switch on mixed mode debug/unmanaged debugging
    5. Ensure that symbols are being generated and stored in the correct location (*.pdb)
    6. Failing all of that, you can poke around in the System event viewer and look for any weird errors
    0 讨论(0)
  • 2021-01-18 04:36

    StackOverflowException is usually caused by some method which invokes itself endlessly.

    The fact that it occurs after some time makes me even more adamant about it: you're facing infinite recursion.

    An extremely simple example of this behavior would be:

    void SomeMethod()
    {
        SomeMethod(); // StackOverflowException
    }
    
    0 讨论(0)
提交回复
热议问题