Why .net process exit code not equal to stackoverflow exception exit code?

0

I have .Net console application that may throw Stackoverflow exception. Based on answer here How does the well-known "Process is terminated due to StackOverflowException" screen appears made by Hans Passant, when application failed because of StackOverflow exception it should return COR_E_STACKOVERFLOW result code.

I've looked through .net 2 source code, and here is that constant:

    internal const int COR_E_STACKOVERFLOW = unchecked((int)0x800703E9); 

And the code for StackOverflow is such:

void DECLSPEC_NORETURN EEPolicy::HandleFatalStackOverflow(EXCEPTION_POINTERS *pExceptionInfo, BOOL fSkipDebugger)
{
  // This is fatal error.  We do not care about SO mode any more.
  // All of the code from here on out is robust to any failures in any API's that are called.
  ....

  DisplayStackOverflowException();

  TerminateProcess(GetCurrentProcess(), COR_E_STACKOVERFLOW);
  UNREACHABLE();
}

That equals to -2147023895. (Here is sample - http://www.dotnetfiddle.net/1rAvoF)

I start my console application from another application, and after that I check for process.ExitCode

But exit code that I've got is -1073741571, and it's not equal to stackoverflow exception code.

Why it returns different exit code?

.net
process
exit-code
stack-overflow
asked on Stack Overflow Nov 24, 2013 by Sergey Litvinov • edited May 23, 2017 by Community

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0