Fix terminateHandler() on macOS #563
Queued
edolstra wants to merge 3 commits into
Queued
Conversation
is-logic-error.hh relied on <cxxabi.h> declaring the Itanium ABI RTTI classes (__cxxabiv1::__si_class_type_info and its __base_type member). Only libstdc++'s <cxxabi.h> does that; libc++abi keeps them in its private, uninstalled private_typeinfo.h, so building with -stdlib=libc++ on Linux failed with error: no type named '__si_class_type_info' in namespace '__cxxabiv1' Since the layout of these classes is fixed by the Itanium C++ ABI (https://itanium-cxx-abi.github.io/cxx-abi/abi.html#rtti) and libc++abi exports their vtables/type infos, declare the parts we need ourselves when not using libstdc++ headers. (macOS was unaffected only because the interposer is Linux-only in meson.build.) Assisted-by: Claude Fable 5 <noreply@anthropic.com>
On macOS, calling std::set_terminate(nullptr) to restore the original terminate handler is ineffective, since std::terminate() calls the handler recorded in the exception. So we end up in an infinite recursion of terminateHandler() calls, which eventually overflows the stack, leading to an unhelpful crash report. So instead, just call onTerminate() to print the stack trace and abort. (On Linux / libstdc++, std::terminate() calls the global terminate handler so we don't have this issue.)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughCrash termination handling now uses a shared ChangesCrash termination handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant terminateHandler
participant onTerminate
participant logFatal
terminateHandler->>onTerminate: delegate termination
onTerminate->>logFatal: log current exception and crash message
onTerminate->>onTerminate: call abort
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
cole-h
approved these changes
Jul 14, 2026
Any commits made after this event will not be merged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
On macOS, calling
std::set_terminate(nullptr)to restore the original terminate handler is ineffective, sincestd::terminate()calls the handler recorded in the exception. So we end up in an infinite recursion ofterminateHandler()calls, which eventually overflows the stack, leading to an unhelpful crash report.So instead, just call
onTerminate()to print the stack trace and abort.(On Linux / libstdc++,
std::terminate()calls the global terminate handler so we don't have this issue.)Also added some hackery to make the __cxa_throw interposer build with libc++ on Linux, and added an
abortmode tonix __crash.Context
Summary by CodeRabbit
New Features
abortoption to the crash-testing command, allowing users to simulate process termination explicitly.Bug Fixes
Tests
abortscenario alongside existing crash types.