signal handlers not async signal safe
Signal handlers are highly constrained in what functions they can call. In particular, they can't
free because mutexes in glibc may already be held by the interrupted thread, resulting in a deadlock. See https://man7.org/linux/man-pages/man7/signal-safety.7.html.
Our signal handlers (in Signals.c) end up calling
vfprintf in at least
rtsSysErrorMsgFn and the libdw backtrace code. I think in practice this is fine, so long as you don't try to format floats.
Chromium have a BSD-ish licensed
safe_sprintf in C++ here: https://chromium.googlesource.com/chromium/src/base/+/master/strings/safe_sprintf.h
I understand mysql has one too, but I haven't looked for it.
EDIT: On further investigation, the dwarf backtrace (in Libdw.c) code calls malloc/free. I haven't investigated whether libdw call's malloc internally.
- GHC version used: master
- Operating System: Linux
- System Architecture: