From Xojo Documentation
Occurs when the calling chain becomes too long.
A StackOverflowException occurs when the stack overflows. This happens when the calling chain gets too long. This can easily happen when your code makes a recursive call without providing a way to terminate the recursion-or the condition that terminates the recursive call takes too many calls to occur.
The following method calls itself until the stack overflows:
You can handle the function with the following simple Exception handler:
If err IsA StackOverflowException Then
MessageBox("The stack has overflowed!")