r/cpp • • Apr 19 '26

Adding Stack Traces to All C++ Exceptions

https://werwolv.net/posts/cpp_exception_stacktraces/
120 Upvotes

27 comments sorted by

View all comments

Show parent comment

1

u/WerWolv Apr 19 '26

You seem to be right, they inject themselves by overwriting `__cxa_allocate_exception` instead of `__cxa_throw` and going the dynamic linker path I mentioned. Don't think that will work properly though when statically linking but in the general case, their implementation ends up doing pretty much the same thing

https://github.com/boostorg/stacktrace/blob/902537345a72cab9063e5eaa1d7f2e2df5cf1864/src/from_exception.cpp#L233