Stack trace generation involves unwinding the stack to find all the return addresses followed by some sort of debug info parsing (be it embedded DWARF data or reading from a pdb file on disk) and then using that to generate the file, function and line information that will be displayed in the stack trace.
That's how std::stacktrace and co work in general though, doesn't change by having it happen for exceptions
The issue is that code might be compiled without frame pointers. On Linux, unwinding the stack involves looking up and interpreting DWARF bytecode in order to reconstruct the frame pointer from the (instruction pointer, stack pointer) pair. For code where debug symbols were stripped, it might be impossible to walk the stack. DWARF was intended for debuggers and is optimized for small size of debug symbols, not for fast extraction of the necessary information.
View all comments
Show parent comment
2
u/SkoomaDentist Antimodern C++, Embedded, Audio Apr 19 '26
What on earth is it doing if even the ”fast” case is millions of cycles?