简体   繁体   English

内存转储未在C ++发布模式下写入

[英]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. 我一直在使用http://www.codeproject.com/Articles/1934/Post-Mortem-Debugging-Your-Application-with-Minidu从我的应用程序中获取转储文件,该文件总是在另一个系统上崩溃。

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. 所以我所拥有的是Header文件和CPP,并且在调试模式下,但没有附加调试器,它询问我是否要创建dmp文件,然后崩溃,但在发布模式下,它只是崩溃。

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. 再次,如果执行从调试模式创建的exe,我得到的文件就好了,发布后我什么都没得到。 This is with 64 bit code in both cases. 在两种情况下都使用64位代码。 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. 我使用的Minidumpwriter来自上述网站。

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. 要调用API,您需要通过使用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 . 在某些未处理的异常中,例如双栈故障,操作系统将立即终止应用程序而不调用过滤器或JIT调试器

Anyway, I personally prefer to use WinDbg in such cases. 无论如何,我个人更喜欢在这种情况下使用WinDbg。 Just attach to a remote process with it and get that dump. 只需使用它附加到远程进程并获取该转储。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM