首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在调试时使用MiniDumpWriteDump() Win32 API的异常

在调试时使用MiniDumpWriteDump() Win32 API的异常
EN

Stack Overflow用户
提问于 2018-11-13 13:41:29
回答 1查看 577关注 0票数 1

我从C++/CLI中的进程"1“中派生出一个进程"2”。当两个进程都在运行时,进程"1“会杀死进程"2”(按设计)。我的目标是在杀死它之前制造一个迷你垃圾场"2“。

这是我的代码:

代码语言:javascript
复制
// mpProcess started with System::Diagnostics::Process... etc.
System::IO::FileStream^ fs = gcnew System::IO::FileStream("MyPath.dmp");

MiniDumpWriteDump( mpProcess->Handle.ToPointer(), mpProcess->Id, fs->SafeFileHandle->DangerousGetHandle().ToPointer(), MINIDUMP_TYPE::MiniDumpNormal, nullptr, nullptr, nullptr);
fs->Close();

当我从命令行启动进程"1“时,没有将它附加到调试器,它将正常运行,启动进程"2”,然后转储它,然后终止它。

当我在调试器中启动进程"1“时,当我跨过对AccessViolationException的调用时,我得到了2-3个MiniDumpWriteDump,但是如果我单击”继续“,一切都会很好,并生成转储文件。

怎么一回事?我的设计有什么问题吗?注意,这是我第一次使用这个API,我甚至不知道24小时前我可以转储这样的文件;-)!我将感谢您的帮助,以提高我的技能与转储文件。

编辑1添加了异常信息:

这是我得到的信息:

在mscordacwks.dll: 0xC0000005:访问冲突读取位置0x00000000000000中在0x000007FED860FD31 (MYProg.exe)引发的异常。

如果存在此异常的处理程序,则可以安全地继续该程序。

编辑2添加了一个片段和一个堆栈跟踪

过程1:“杀手”

代码语言:javascript
复制
// Process1.cpp : main project file.

#include "stdafx.h"

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <dbghelp.h>

using namespace System;

int main(array<System::String ^> ^args)
{
     Console::WriteLine(L"Hello, I'm Process1! I'll \"minidump\" Process2 then kill it!");

    System::Diagnostics::Process^ p = gcnew System::Diagnostics::Process();

    p->StartInfo->FileName = "Process2.exe";
    p->Start();

    System::Threading::Thread::Sleep( 3000 );

    System::IO::FileStream^ fs = gcnew System::IO::FileStream( "minidump.dmp", System::IO::FileMode::Create );

    MiniDumpWriteDump( p->Handle.ToPointer(), p->Id, fs->SafeFileHandle->DangerousGetHandle().ToPointer(), MINIDUMP_TYPE::MiniDumpNormal, nullptr, nullptr, nullptr );

    fs->Close();

    p->Kill();

    return 0;
}

过程2:“倾倒”

代码语言:javascript
复制
// Process2.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)
{
    Console::WriteLine(L"Hello, I'm Process2! I'm waiting to be killed by Process1!");

    // Do nothing, wait to be killed
    while ( true )
    {
        System::Threading::Thread::Sleep( 1000 );
    }

    return 0;
}

当我从()异常对话框中中断它时,堆栈跟踪它:

代码语言:javascript
复制
mscordacwks.dll!000007fed860fd31()  Unknown
mscordacwks.dll!000007fed861028c()  Unknown
mscordacwks.dll!000007fed8610fd2()  Unknown
mscordacwks.dll!000007fed861165f()  Unknown
mscordacwks.dll!000007fed861176e()  Unknown
dbghelp.dll!GenGetAuxMemory(struct _MINIDUMP_STATE *,struct _INTERNAL_PROCESS *)    Unknown
dbghelp.dll!GenGetProcessInfo(struct _MINIDUMP_STATE *,struct _INTERNAL_PROCESS * *)    Unknown
dbghelp.dll!MiniDumpProvideDump()   Unknown
dbghelp.dll!MiniDumpWriteDump() Unknown
[Managed to Native Transition]  
[CURSOR]>>> Process1.exe!main(array<System::String^>^ args=array<System::String^>(0)) Line 24   C++
Process1.exe!mainCRTStartupStrArray(array<System::String^>^ arguments=array<System::String^>(0)) Line 249   C++
[Native to Managed Transition]  
mscoreei.dll!000007feee467a6d() Unknown
mscoree.dll!_CorExeMain_Exported()  Unknown
kernel32.dll!BaseThreadInitThunk()  Unknown
ntdll.dll!RtlUserThreadStart()  Unknown
EN

回答 1

Stack Overflow用户

发布于 2021-02-17 13:40:36

就像上面的评论中提到的Hans一样,这似乎是一个内部/被发现的例外。MiniDumpWriteDump执行一些导致异常并捕获其内部异常并继续执行的操作。我真的不知道它为什么会这么做。你可以无视它继续下去。看起来是无害的。

我在调用其他(不透明)系统API调用时遇到了类似的问题。调用本身在内部捕获自己的异常。调试器不知道它们是否会被捕获并破坏它们。

它们不应该出现在发布模式中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53282342

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档