Changeset 0d2cd10 for configure


Ignore:
Timestamp:
2018-03-26T16:48:32Z (7 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
230f6f1
Parents:
e1e5bd6
git-author:
dequis <dx@…> (26-03-18 16:26:56)
git-committer:
dequis <dx@…> (26-03-18 16:48:32)
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • configure

    re1e5bd6 r0d2cd10  
    485485'
    486486
     487BACKTRACE_TESTCODE='
     488#include <execinfo.h>
     489
     490int main()
     491{
     492        void *trace[16];
     493        return backtrace(trace, 16);
     494}
     495'
     496
    487497detect_resolv_dynamic()
    488498{
     
    582592}
    583593
     594detect_backtrace()
     595{
     596        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
     597        ret=1
     598        echo "$BACKTRACE_TESTCODE" | $CC -o $TMPFILE -x c -  >/dev/null 2>/dev/null
     599        if [ "$?" = "0" ]; then
     600                ret=0
     601        fi
     602
     603        rm -f $TMPFILE
     604        return $ret
     605}
     606
    584607if [ "$ssl" = "auto" ]; then
    585608        detect_gnutls
     
    647670fi
    648671
     672if detect_backtrace; then
     673        echo '#define HAVE_BACKTRACE' >> config.h
     674        echo '#define CRASHFILE "'$config'crash.log"' >> config.h
     675fi
    649676
    650677STORAGES="xml"
Note: See TracChangeset for help on using the changeset viewer.