Stack overflow condition is maybe not the easiest for debugging, but it's one of the easiest. You cannot ask a question every time it happens but really want to learn how to sort out such problems all by yourself.
Here are some basic ideas. If stack overflow happens as a result of some bug, it's nearly always happens due to incorrect
recursion or
mutual recursion:
https://en.wikipedia.org/wiki/Recursion[
^],
https://en.wikipedia.org/wiki/Recursion_(computer_science)[
^],
https://en.wikipedia.org/wiki/Mutual_recursion[
^],
https://en.wikipedia.org/wiki/Recursive_function[
^].
If you know which of your recursive function written on purpose is a source of a problem, you can just debug it in a usual way. But what if you don't know where the problem is?
First, when you observer this exception, put a break point, at first, at the very first statement of the method shown where the exception happens under the debugger (in Visual Studio, you may want to adjust Debug/Exceptions settings). Restart the application and reproduce the condition. When the execution stops at this point, continue execution to see how this point is reached again and again.
Now, this is the key: use the debugger window "Call stack" to see where the call comes from each time. Using this information, move or add the breakpoint to the point in code closer to the source of this problem. This way, you methodically pin-point the source of the problem in few such iteration steps.
—SA