What Really Happens When You Start Panicking in Rust
summary
Explains that calling panic! or panic_any either hands a formatted message or an arbitrary payload to a panic handler, with panic_any payload trick used by the compiler to mark owned panics; standard library installs a global handler and composable panic hooks while runtime chooses abort or unwind. Unwinding relies on DWARF/LSDA tables and a C++-compatible personality function, so using extern "C-unwind" or compiling C/C++ with -fexceptions lets panics cross language boundaries. Unwinding adds about ~10% binary size and significant complexity (cleanup code, mutex poisoning, optimizer limits).
AI-written summary · about
chapters (18)
- 0:00Introduction to panic in Rust
- 1:08Talk scope and assumptions
- 2:13Entry points to panic machinery
- 3:37Core panic behavior explained
- 5:20Standard library panic handler
- 7:24Panic hooks and customization
- 8:49Panic runtime options
- 10:34Unwinding as exception handling
- 11:40Normal program execution flow
- 13:08Panic flow and stack unwinding
- 14:14Unwinding metadata in binaries
- 15:38Cleanup code during unwinding
- 17:46LSDA and personality functions
- 20:34Bonus: panic any use case
- 23:05Rust C++ interoperability
- 24:34Zero-cost exceptions myth
- 25:57Complexity of unwinding
- 27:41Q&A and closing
