Exceptions Explained Part 4: C++

After quite the lengthy tread through GCC and C-land (mind you everything discussed before was written in C), we finally find ourselves back at C++. C++ exception semantics seem simple, but actually hide many surprising edge cases. Functions Like before, let’s discuss the API of the C++ exception handling regime. Note that while you’re not supposed to call these functions directly, these functions are called in compiler generated code anyways, so are a part of the public ABI....

2025-01-15 · Shin Umeda

Exceptions Explained Part 3: libunwind

Last time I mentioned libunwind, but now I’m going to go over the implementation of libunwind in GCC. As mentioned before, libunwind used to be a library developed by HP, but it got vendored into GCC as a part of libgcc. libgcc itself is a small library containing, besides libunwind, various intrinsics for floating point and integer math. libunwind One might reasonably ask the question of how one can unwind a stack while using functions that modify the stack?...

2025-01-15 · Shin Umeda

Exceptions Explained Part 2: Frame Information

Last time I talked about the broad architecture of how exceptions work. Today I’m focusing on how debug information is contained in the eh_frame section. To explain why exception information is held in the format it is today, we need to dive a little into the history of libunwind. Much of what is here comes from linux reference documents, found here. History Libunwind was originally developed by HP back in the days of the unix wars....

2025-01-15 · Shin Umeda

Exceptions Explained Part 1: Architecture

As it turns out there’s not really a good in depth explanation of how exceptions work. There are disparate explanations of how separate parts of exceptions in C++ work, but not really the whole picture. So I’m writing this down here as a reference to how everything in C++ exceptions work. Disclaimer My experiences are exclusively in GCC. Broadly, Clang should follow the same Architecture as GCC, but may vary in implementation details....

2025-01-13 · Shin Umeda