Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

boost.coroutine2 cannot generate dump

未关闭
#53 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
cpp

调研方向

首先,在使用和不使用 boost.coroutine2 的情况下分别复现所提供的 Windows 示例,重点关注 CreateMiniDump、MyUnhandledExceptionFilter 和 CoroutineFunction。比较两种情况下的异常处理行为,并检查失败路径中涉及的 coroutine2 实现。确定原因并提供经过测试的修复方案或记录在案的限制后,即视为完成。

由索引模型根据 Issue 内容生成。

描述

windows, using boost.coroutine2, cannot generate dump (using mini dump) if a crash occurs in the coroutine function. As long as boost.coroutine2 is not used, the dump file can be generated. Is there something I'm missing?
Here is the code example:

#include <boost/coroutine2/all.hpp>
#include <Windows.h>
#include <dbghelp.h>
#include <iostream>

#pragma comment(lib, "Dbghelp.lib") 

void CreateMiniDump(EXCEPTION_POINTERS* pep) {
    HANDLE hFile = CreateFile(
        "crashdump.dmp",          // File name
        GENERIC_WRITE,             // Desired access
        0,                         // Share mode
        NULL,                      // Security attributes
        CREATE_ALWAYS,             // Creation disposition
        FILE_ATTRIBUTE_NORMAL,     // Flags and attributes
        NULL                       // Template file
    );

    if (hFile != INVALID_HANDLE_VALUE) {
        MINIDUMP_EXCEPTION_INFORMATION mdei;
        mdei.ThreadId = GetCurrentThreadId();
        mdei.ExceptionPointers = pep;
        mdei.ClientPointers = FALSE;

        BOOL rv = MiniDumpWriteDump(
            GetCurrentProcess(),
            GetCurrentProcessId(),
            hFile,
            MiniDumpNormal,
            &mdei,
            NULL,
            NULL
        );

        if (rv == FALSE) {
            std::cerr << "MiniDumpWriteDump failed: " << GetLastError() << std::endl;
        }

        CloseHandle(hFile);
    }
}

// Exception filter to handle crashes
LONG WINAPI MyUnhandledExceptionFilter(EXCEPTION_POINTERS* pExceptionPointers) {
    CreateMiniDump(pExceptionPointers);
    return EXCEPTION_EXECUTE_HANDLER;
}
#pragma optimize("", off)
void CoroutineFunction(boost::coroutines2::coroutine<void>::push_type& yield) {
    // Example code that may crash
    std::cout << "CoroutineFunction Begin\n";
    int* p = nullptr;
    *p = 0; // This will cause a crash
    std::cout << "CoroutineFunction End\n";
}
#pragma optimize("", on)
int main() {
    SetUnhandledExceptionFilter(MyUnhandledExceptionFilter);

    //
    //int* p = nullptr;
    //*p = 1000;
    
    // Use Boost.Coroutine2
    try {
        boost::coroutines2::coroutine<void>::pull_type source(
            [](boost::coroutines2::coroutine<void>::push_type& sink) {
                CoroutineFunction(sink);
            }
        );
    }
    catch (const std::exception& e) {
        std::cout << "Exception: " << e.what() << std::endl;
    }

    std::cout << "sssssssssssssssssssssssssssss\n";

    char ch;
    std::cin >> ch;

    return 0;
}
主要语言
C++
星标
139
派生
44
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

boostorg/coroutine2 的其他 Issue

查看 boostorg/coroutine2 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。