0

I get an appcrash with execution code c00000fd (STATUS_STACK_OVERFLOW) in ntdll.dll.

Does that mean there was a stack overflow somewhere in native code, outside my managed code? Because for managed code, we have System.StackOverflowException. But there is none in my case, and no stack trace that could provide a clue.

Evgeniy Berezovsky
  • 18,571
  • 13
  • 82
  • 156

1 Answers1

3

You cant catch System.StackOverflowException any more

Starting with .Net 2.0 they can only be caught in the following circumstances.

  • The CLR is being run in a hosted environment where the host specifically allows for StackOverflow exceptions to be handled
  • The stackoverflow exception is thrown by user code and not due to an actual stack overflow situation (Reference)

Although the error says it occurred in ntdll.dll it is most likely caused form your code.

My first steps would be to add, or turn on your highest debug logging in production, so you can try to narrow down where it's happening and the circumstances.

Second I'd start debugging (attaching the debugger) and scrutinising that method class until you find it. Most likely it's due to some recursion, that's the first place I'd start looking.


Additional Resources and references

C# catch a stack overflow exception

How to find the source of a StackOverflowException in my application

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

How do I prevent and/or handle a StackOverflowException?

How to debug a stackoverflowexception in .NET

Troubleshooting Exceptions: System.StackOverflowException

StackOverflowException Class

In the .NET Framework 1.0 and 1.1, you could catch a StackOverflowException object (for example, to recover from unbounded recursion). Starting with the .NET Framework 2.0, you can’t catch a StackOverflowException object with a try/catch block, and the corresponding process is terminated by default. Consequently, you should write your code to detect and prevent a stack overflow. For example, if your app depends on recursion, use a counter or a state condition to terminate the recursive loop.

halfer
  • 19,824
  • 17
  • 99
  • 186
TheGeneral
  • 79,002
  • 9
  • 103
  • 141