Search code examples
c++exceptioncrash-dumps

Memory Dump not being written in C++ Release mode


I've been using http://www.codeproject.com/Articles/1934/Post-Mortem-Debugging-Your-Application-with-Minidu to get a dump file from my application which always crashes on another system.

So what I have is that Header file and CPP and in Debug Mode, but with no debugger attached, it asks me whether I want the dmp file created or not, and then crashes, but in release mode, it just crashes.

Basically the code I've been using is

void IndexFault(int n)
{
    unsigned char* smallArray = new unsigned char[4];
    printf((const char*)smallArray[n]);
}

MiniDumper* mDump = new MiniDumper("Dumpfile");

int main()
{
    IndexFault(4);
    return 0;
}

Again, if executing the exe created from Debug mode, I get the file just fine, with release I get nothing. This is with 64 bit code in both cases. I will apply this to my real code once this is working, but as of now, I cannot figure out what's going on. The Minidumpwriter I use is from the website as stated above.


Solution

  • I believe you missed this step:

    To call the API, you need to catch the crash by setting an unhandled exception handler with the SetUnhandledExceptionFilter API. This allows the filter function to be called at almost any time an unhandled exception occurs in an application. In certain unhandled exceptions, such as a double stack fault, the operating system will immediately terminate the application without calling the filter or a JIT debugger.

    Anyway, I personally prefer to use WinDbg in such cases. Just attach to a remote process with it and get that dump.