Bus error when Catch2 tries catching an exception when using Clang 19

未关闭
#2,913 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
cpp
领域
testing-qa

调研方向

从 issue 中的最小 C++ 复现开始,使用 Catch2 v3.7.1 和 Clang 19.1 在 macOS 15 上构建,并确认 Catch2 处理抛出的异常时会出现总线错误。将普通异常处理与 REQUIRE_THROWS 进行比较;当 Catch2 不再崩溃并产生合理的输出,且有一个涵盖该行为的匹配测试时,即视为完成。

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

描述

Describe the bug
When Catch2 catches an exception thrown by test code in Clang 19.1 (at least the version I have installed using homebrew on my Mac), it results in a Bus error: 10. This occurs regardless of whether or not the exception is raised inside a REQUIRE macro, so long as the exception is caught by Catch2. (If I set up a try block to catch the exception myself before any Catch2 code sees it, it doesn't seem to cause a problem.)

Expected behavior
Catch2 should catch the exception and produce some kind of reasonable output. If in a REQUIRE_THROWS macro where an appropriate exception is raised, the test should pass.

Reproduction steps
This test file was enough to trigger the problem for me:

#define CATCH_CONFIG_MAIN
#include "catch2/catch_test_macros.hpp"


TEST_CASE( "blah", "blah" ) {

  SECTION( "blah" ) {
    throw(std::runtime_error("Hi"));
  }

}

I typically get output like this:

Randomness seeded to: 638767569
Bus error: 10

Platform information:

  • OS: macOS 15
  • Compiler+version: Clang 19.1 (from homebrew)
  • Catch version: v3.7.1 (compiled from source with same version of Clang)
主要语言
C++
星标
21.6k
派生
3.4k
平均合并
3 天 12 小时
30 天内合并 PR
5

环境准备

从这里开始

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

catchorg/Catch2 的其他 Issue

查看 catchorg/Catch2 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

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