Enable core dumps on Raspbian - dresden-elektronik/deconz-rest-plugin GitHub Wiki
In the rare case that deCONZ crashes, a core dump file will help in analysing the cause. Unfortunately, Raspbian has disabled core dumps by default. This page explains how to enable them.
/etc/security/limits.d/core.conf
1. Create $ sudo -i
# cat > /etc/security/limits.d/core.conf <<+++
root hard core unlimited
root soft core unlimited
* hard core unlimited
* soft core unlimited
+++
/etc/systemd/system.conf
2. Edit Change the line
#DefaultLimitCORE=
to
DefaultLimitCORE=infinity
/etc/sysctl.d/core.conf
3. Create # cat > /etc/sysctl.d/core.conf <<+++
kernel.core_pattern = /var/lib/coredumps/core-%e-sig%s-user%u-group%g-pid%p-time%t
kernel.core_uses_pid = 1
fs.suid_dumpable = 2
+++
/var/lib/coredumps
4. Create # mkdir /var/lib/coredumps
# chmod 1777 /var/lib/coredumps
# ls -ld /var/lib/coredumps
drwxrwxrwt 2 root root 4096 Sep 23 15:39 /var/lib/coredumps/
5. Reboot
# shutdown -r now
ulimit
6. Check $ ulimit -c
unlimited
7. Test
Find out the process ID of the deCONZ service:
$ sudo systemctl status deconz-gui
โ deconz-gui.service - deCONZ: ZigBee gateway -- GUI/REST API
Loaded: loaded (/lib/systemd/system/deconz-gui.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/deconz-gui.service.d
โโoverride.conf
Active: active (running) since Sun 2018-09-23 16:28:11 CEST; 19s ago
Main PID: 17835 (deCONZ)
CGroup: /system.slice/deconz-gui.service
โโ17835 /usr/bin/deCONZ --http-port=80 --dbg-info=2 --dbg-aps=2 --dbg-error=1
โโ17858 dbus-launch --autolaunch 36338e1dca924dbd9a2413fc1346afd5 --binary-syntax --close-stderr
โโ17859 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
[...]
Notice the Main PID, 17835
in this example. Send an abort (signal 6) to the deCONZ service using the main PID:
$ sudo kill -6 17835
Check that the service stops and that a core dump file is created:
$ sudo systemctl status deconz-gui
โ deconz-gui.service - deCONZ: ZigBee gateway -- GUI/REST API
Loaded: loaded (/lib/systemd/system/deconz-gui.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/deconz-gui.service.d
โโoverride.conf
Active: deactivating (stop-sigterm) (Result: core-dump) since Sun 2018-09-23 16:30:59 CEST; 2s ago
Process: 17835 ExecStart=/usr/bin/deCONZ $DECONZ_OPTS (code=dumped, signal=ABRT)
Main PID: 17835 (code=dumped, signal=ABRT)
CGroup: /system.slice/deconz-gui.service
โโ17858 dbus-launch --autolaunch 36338e1dca924dbd9a2413fc1346afd5 --binary-syntax --close-stderr
[...]
$ ls -l /var/lib/coredumps/
total 18064
drwxrwxrwt 2 root root 4096 Sep 23 16:30 ./
drwxr-xr-x 45 root root 4096 Apr 25 19:18 ../
-rw------- 1 pi pi 121974784 Sep 23 16:30 core-deCONZ-sig6-user1000-group1000-pid17835-time1537713059
Before sending or attaching a core dump file, please compress it:
$ gzip /var/lib/coredumps/core-deCONZ-sig6-user1000-group1000-pid17835-time1537713059
$ ls -l /var/lib/coredumps/
total 2360
drwxrwxrwt 2 root root 4096 Sep 23 16:36 ./
drwxr-xr-x 45 root root 4096 Apr 25 19:18 ../
-rw------- 1 pi pi 2407701 Sep 23 16:30 core-deCONZ-sig6-user1000-group1000-pid17835-time1537713059.gz
8. Obtaining a Stack Trace
To obtain a stack trace, run gdb
and issue the bt
command at the (gdb)
prompt:
$ gdb /usr/bin/deCONZ /var/lib/coredumps/core-deCONZ-sig6-user1000-group1000-pid17835-time1537713059
...
(gdb) bt
...