aboutsummaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2018-03-26 13:26:56 -0300
committerdequis <dx@dxzone.com.ar>2018-03-26 13:48:32 -0300
commit0d2cd10fba86011a01a1c52c0db2e98660efa1de (patch)
treed9ca0c61028383aab9bcd953b5b52990d7dfe05c /configure
parente1e5bd67665452dbc300234b1b4ab7709e83f85d (diff)
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.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure27
1 files changed, 27 insertions, 0 deletions
diff --git a/configure b/configure
index 093fbf3d..b578164f 100755
--- a/configure
+++ b/configure
@@ -484,6 +484,16 @@ int main()
}
'
+BACKTRACE_TESTCODE='
+#include <execinfo.h>
+
+int main()
+{
+ void *trace[16];
+ return backtrace(trace, 16);
+}
+'
+
detect_resolv_dynamic()
{
case "$arch" in
@@ -581,6 +591,19 @@ detect_nameser_has_ns_types()
return $ret
}
+detect_backtrace()
+{
+ TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
+ ret=1
+ echo "$BACKTRACE_TESTCODE" | $CC -o $TMPFILE -x c - >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]; then
+ ret=0
+ fi
+
+ rm -f $TMPFILE
+ return $ret
+}
+
if [ "$ssl" = "auto" ]; then
detect_gnutls
if [ "$ret" = "0" ]; then
@@ -646,6 +669,10 @@ else
echo 'Insufficient resolv routines. Jabber server must be set explicitly'
fi
+if detect_backtrace; then
+ echo '#define HAVE_BACKTRACE' >> config.h
+ echo '#define CRASHFILE "'$config'crash.log"' >> config.h
+fi
STORAGES="xml"