dmlc / dmlc-core

A common bricks library for building scalable and portable distributed machine learning.
Apache License 2.0
864 stars 520 forks source link

[Feature] stack trace printing in signal handlers #630

Open szha opened 4 years ago

szha commented 4 years ago

Currently in DMLC core the utility for printing stacktrace (and demangling) are the following:

https://github.com/dmlc/dmlc-core/blob/ebcaa42d0b7271265e6a02ff468c6753a8fbecdb/include/dmlc/logging.h#L49-L96

The problem with them is that they can't be used safely in asynchronous signal handlers, for which non-reentrant functions are required.

According to boost, there isn't a safe way to get stacktrace that's portable. On the other hand, one was described in this blog. The downside is that on windows it relies on StackWalker. There may be better, more modern ways to achieve this that I missed.