For a process that typically runs on Windows, the process exit code is usually either the return value from main or the exit code passed to std::exit . %ERRORLEVEL% can then be used to request an exit code, and this can be used to determine if the program was executed correctly, or there were some exceptional inputs / failures that indicate a specific problem (application specificity).
However, I am interested in the exit code if the process crashes. Take a very simple sample program:
int main() { int * a = nullptr; *a = 0xBAD; return 0; }
When I compile this and run on Windows, at the command prompt I get:
MyCrashProgram.exe -> crashes echo %ERRORLEVEL% -> -1073741819
The exit code is a number. This leads me to a few questions:
- Was the exit code
-1073741819 somehow predictable based on an invalid write error? - If so, is there a way to determine the type of failure based on the exit code?
- Does this change using the compiler (I used MSVC 2012)?
- Does this change using the version of Windows used (I used Win10 TP)?
- Does this change with architecture (e.g. x64 - I used Win32)?
Notice I'm not interested in how to change a program to catch an exception. I am interested in classifying crashes that can occur in existing programs that I cannot change.
source share