Write backtrace to /var/lib/bitlbee/crash.log on SIGSEGV
Async-signal-safe code is very restricted (nothing that may call malloc
indirectly), so this code tries its best to show meaningful stuff, but
the output is still fairly raw. The contents of the log file are:
- BITLBEE_VERSION, BITLBEE_CONFIGURE_ARGS
- Backtrace as generated by backtrace()/backtrace_symbols_fd()
- A small help text explaining how to get more useful symbol names
- Memory maps (/proc/self/maps), which also mentions loaded plugins
The backtrace() function is a GNU extension, /proc/ is a linux thing.
Non-glibc platforms (such as musl) won't show anything, non-linux
platforms will skip the memory maps when /proc/self/maps fails to open.
I'd like to include timestamps, but I can't find a safe way to format
them. Even turning raw unix timestamps to strings is hard. Fun stuff.
I used the config directory because it's the only place we can be sure
we can write to. The filename is hardcoded for the same reason there are
no timestamps.