0

A daemon is started and running under Debian until it randomly crashes. I found out that it sometimes aborts due to an assertion which is shown if the process is running in foreground, like:

/usr/include/boost/smart_ptr/shared_ptr.hpp:424: T* boost::shared_ptr::operator->() const [with T = libcage::dht::query]: Assertion `px != 0' failed. Aborted

The exitcode is 134, but how to save the more detailed error description (there could be many different) into a logfile for a later analysis, if the process is running in background?

"2> /log/mylogfile" is writing nothing and "> /log/mylogfile" is writing the process output ignoring the abort message. Also in "dmesg" or "kern.log" is nothing.

Achim
  • 283
  • 3
  • 13
  • If this is on RHEL or CentOS 6 or 7 (or probably other derivatives), [`abrtd`](https://wiki.centos.org/TipsAndTricks/ABRT) may already be catching it. Look in `/var/spool/abrt` or `/var/tmp/abrt`. – James Sneeringer Sep 18 '17 at 17:48
  • Thanks, but nope, both directories are empty in Debian – Achim Sep 18 '17 at 18:02

2 Answers2

1

You can use strace to see what is wrong. It will log the syscalls used, signals, and return values.

Just strace -v -s 256 -D -o /tmp/daemonlog daemonapp and you can see execution details.

-v: print environment

-s string size: 256 bytes

-D run strace as detached granchild

-o logfile

ThoriumBR
  • 5,302
  • 2
  • 24
  • 34
  • It looks like it is creating a huge logfile for debugging purpose - not feasible for normal daemon running on productive machines... – Achim Sep 18 '17 at 18:08
  • Yes, the intention is to create a logfile for debugging. You can pair it with logrotate and save only the last 10Mb or so. Analyse the logs when there's an error and restart the daemon without strace later. – ThoriumBR Sep 18 '17 at 18:17
-1

If your daemon uses 'bash script', add "set -x" in the beginning of the script and start your process again and see