When writing code we usually focus our attention on the happy paths - that’s where the interesting stuff happens. But there are also plenty of exciting things happening on the error handling flow, too. Although not universally loved/used, exceptions are a powerful mechanism of maneuvering execution on the unhappy path.
Even if std::exception and related machinery are not your cup of tea, you might care about hardware faults or OS signals like access violations, page errors, ALU overflows.
Let’s take a deep dive and explore what happens when an exception occurs, both at the application level and the OS level. We’ll explore the unwind process, the compiler generated code, the CRT hooks available and other exception internals. As we’re taking the scenic Windows route, we’re also going to encounter async exceptions (structured exceptions) on our quest for a better crash. We’ll poke into these mechanisms and see how we can leverage them in our application error handling. Did I mention threads? Routing exceptions between threads… oh my!
Victor Ciura is a Principal Engineer at CAPHYON, Technical Lead on the Advanced Installer team and a Microsoft MVP (Developer Technologies).
He’s a regular guest at Computer Science Department of his Alma Mater, University of Craiova, where he gives student lectures & workshops on using C++ STL Algorithms.
Since 2005, he has been designing and implementing several core components and libraries of Advanced Installer. Currently, he spends most of his time working with his team on improving and extending the repackaging and virtualization technologies in Advanced Installer IDE, helping clients migrate their traditional desktop apps to the modern Windows application format: MSIX.
One of his “hobbies” is tidying-up and modernizing (C++20) the aging codebase of Advanced Installer and has been known to build tools that help this process: Clang Power Tools