Can one use libSegFault.so to get backtraces for SIGABRT?

前端 未结 2 1259
挽巷
挽巷 2021-01-31 17:27

The magic incantation

LD_PRELOAD=/lib/libSegFault.so someapp

runs someapp with libSegFault.so providing backtrace information on a

2条回答
  •  天命终不由人
    2021-01-31 18:19

    In a similar vein, the glibc exception handler writes a stack dump to /dev/console on heap corruption errors.

    If you are running your executable in a non tty (i.e. a systemd process or other detached process), the crash output goes to /dev/null, which is not so useful.

    There is an undocumented feature to redirect the output to /dev/stderr. Set the following environment variable:

    export LIBC_FATAL_STDERR_=1
    

    This can be used in conjunction with libSegFault.so for maximal forensics.

    It is also worth mentioning that this might give you two stack traces if you also enable backtraces for SIGABRT, as the glibc first does a stack trace, then signals SIGABRT ... and then libSegFault gives a second stack trace.

提交回复
热议问题