Once you hit the stack overflow, you are pretty unlucky for debugging the problem - flushing your stack space leaves your program in a non-deterministic state, so you cannot rely on any information in this place - any stack trace you are trying to get can be damaged and can easily point you in the wrong direction. That is, as soon as a StackOverflowException occurs, it is too late.
Also, according to the documentation , you cannot catch a StackOverflowException with .Net 2.0, so other suggestions to surround your attempt / catch code for this probably won't work. That makes sense, given the side effects (I'm surprised .Net has ever let you catch it).
Your only real option is to get bored with code analysis, search for something that could potentially lead to a stack overflow, and place some markers so that you can get an idea of where they occur before they happen. For example, it’s obvious that all recursive methods are the first place to start, so give them a depth counter and throw your own exception if they get some kind of “unreasonable” value that you define, so you can actually get a valid stack trace .
Not sur
source share