Skip to content

vendor: GCC 15 (Homebrew, macOS arm64) -mbranch-protection=pac-ret breaks C++ exception unwinding #327

Open

Description

@homer6

Found building the suite hardened (#305) with Homebrew GCC 15.2.0_1 on macOS 14.6.1 (Apple silicon): every test that throws and catches an exception aborts (20 of 1514 tests). Clang 22 (Homebrew LLVM) with the same flag is fine, and so is GCC 16 on Linux aarch64.

Minimal reproducer

#include <stdexcept>
#include <cstdio>
int f(int x) { if (x) throw std::runtime_error("e"); return 0; }
int main(int argc, char**) {
    try { f(argc); } catch (const std::exception&) { std::puts("caught"); return 0; }
    return 1;
}
Flags (g++-15, macOS arm64) Result
-O2 caught, exit 0
-O2 -mbranch-protection=bti caught, exit 0
-O2 -mbranch-protection=pac-ret abort (exit 134)
-O2 -mbranch-protection=pac-ret+b-key abort
-O2 -mbranch-protection=standard / -O0 …standard abort

So return-address signing (pac-ret) breaks unwinding through GCC-compiled frames on Darwin; presumably the system unwinder doesn't handle GCC's signed return addresses there. No existing GCC Bugzilla report found yet (searched for darwin + mbranch-protection/pac-ret + exceptions); a related Clang issue for arm64e + pac-ret is llvm/llvm-project#60239 (different cause).

In the suite: CPPDOCS_HARDEN skips -mbranch-protection for GCC on Apple targets, citing this issue; known-bugs.json records it.

Upstream: drafted here; to be filed with GCC (Bugzilla, target aarch64-apple-darwin) only with the owner's yes.

Activity

  1. self-assigned this
    on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

securityv0.5.0 security work

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions