c++ - 未在 C++ Release模式下编写内存转储

标签 c++ exception-handling crash-dumps

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

所以我拥有的是头文件和 CPP,在 Debug模式下,但没有附加调试器,它询问我是否要创建 dmp 文件,然后崩溃,但在 Release模式下,它只是崩溃。

基本上我一直在使用的代码是

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;
}

同样,如果执行从 Debug模式创建的 exe,我得到的文件很好,发布时我什么也得不到。在这两种情况下都是 64 位代码。一旦它起作用,我将把它应用到我的真实代码中,但截至目前,我无法弄清楚发生了什么。我使用的 Minidumpwriter 来自上述网站。

最佳答案

我相信你错过了这一步:

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.

无论如何,我个人更喜欢在这种情况下使用 WinDbg。只需使用它附加到远程进程并获取该转储。

关于c++ - 未在 C++ Release模式下编写内存转储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13956176/

相关文章:

Tomcat 或 JVM 故障转储文件?

c++ - 如何使用 CGI 流式传输 motion jpeg?

c++ - 每个线程或每个调用一个 ZeroMQ 套接字?

php - PHP异常真的比错误有用吗? (进阶)

python - 用 Python 编写的服务器的强大无限循环

VB6 故障转储符号未解决

windbg - WinDbg 应该慢得令人难以忍受吗?

c++ - 是否可以从 log4j 或 log4cxx 等文件配置 spdlog?

c++ - 包含 qgis 头文件时出错

c++ - 如果分配该数组引发异常,您是否应该释放该数组?