The exception text clearly describes
stack overflow condition.
It can happen because you don't properly go out of
recursion or
mutual recursion:
Recursion - Wikipedia, the free encyclopedia[
^],
Recursion (computer science) - Wikipedia, the free encyclopedia[
^],
Mutual recursion - Wikipedia, the free encyclopedia[
^].
This is the most typical case leading to this exception. The root of the problem usually can be found with the use of the debugger in very few iterations. Here is the idea of one very general technique: you hypothesize what method could be called "infinitely" and put a breakpoint on its first statement. The run your code until it stops on this break point and look at the debug windows "Call stack". Browsing the stack will show you where the call comes from. Repeat to see where it comes from next time, again and again. This way, you can quickly narrow down your search and finally find the ends.
—SA