Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Theoretical async signal safety
PrevUpHomeNext

In theory, walking the stack without decoding and demangling should be async signal safe.

In practice, it is not:

  • Looks like a page fault while dumping the trace on a containerized/virtualized Windows system has a chance to deadlock. Page fault could happen easily as we have to write the dump either to memory or to a file.
  • On POSIX systems a deadlock could happen if a signal is received when throwing an exception #131. Theoretically this could be worked around by bypassing the mutex locking in C++-runtime at exception throw (sample implementation in the 🐙 userver framework), or by using a very modern runtime (glibc-2.35+ with modern libgcc or modern LLVM's libunwind).
  • -fomit-frame-pointer like flags add additional complexity to the stack walking implementation, which may also negatively affect the signal safety.

As a rule of thumb: do not capture stack traces in signal handlers unless you are absolutely sure in your environment and inspected all of its source codes.


PrevUpHomeNext