There's a new tiny package which provides a python traceback logging in the journal for python processes. It's very similar to the existing handler provided by abrt, it also installs itself as sys.excepthook using a .pth file, but instead of communicating with abrt, it talks to systemd-coredump directly.
The advantage is that it provides a backtrace in the journal (in red!), which coredumpctl list/info know about. Various stuff that systemd-coredump gathers (fdinfo, cgroups, mounts, unit, slices, limits, uid, gid, etc) are recorded. No call stack of the process is gathered though, just the python backtrace.
I'm not 100% convinced that this will be useful myself. If you have Python services, maybe. I'd be interested to hear what people think about this.
To try it out: 1. make sure you're on systemd 233 (currently only rawhide or F26) 2. dnf install python3-systemd-coredump (or python2-system-coredump) 3. uninstall or disable abrt (two separate things matter: - systemd-coredump-python checks if systemd-coredump is configured in sysctl kernel.core_pattern, and does nothing if not, - abrt-addon-python3 installs its handler unconditionally and exclusively. So instead of removing abrt it is enough to: systemctl stop abrt* && rm /usr/lib64/python*/site-packages/abrt.pth This conflict should be temporary, the patch to make the abrt handler non-exclusive should be trivial.) 4. run a python script that throws an exception e.g. python3 /usr/lib/python3.5/site-packages/systemd_coredump_exception_handler.py, this should print a traceback to stdout 5. check 'coredumpctl' and 'journalctl' output, a backtrace should be logged.
$ coredumpctl info -1 PID: 29688 (python3) UID: 1000 (zbyszek) GID: 1000 (zbyszek) Reason: ZeroDivisionError Timestamp: Tue 2017-03-14 22:41:41 EDT (6min ago) Command Line: python3 /usr/lib/python3.5/site-packages/systemd_coredump_exception_handler.py Executable: /usr/bin/python3.5 Control Group: /user.slice/user-1000.slice/user@1000.service/gnome-terminal-server.service Unit: user@1000.service User Unit: gnome-terminal-server.service Slice: user-1000.slice Owner UID: 1000 (zbyszek) Boot ID: b3ca39ca747e4cd896e9e5fbb0e07f5e Machine ID: ad18f69b80264b52bb3b766240742383 Hostname: fedora Storage: none Message: Process 29688 (/usr/lib/python3.5/site-packages/systemd_coredump_exception_handler.py) of user zbyszek failed with ZeroDivisionError: division by zero
Traceback (most recent call last): File "/usr/lib/python3.5/site-packages/systemd_coredump_exception_handler.py", line 165, in <module> g() File "/usr/lib/python3.5/site-packages/systemd_coredump_exception_handler.py", line 164, in g f() File "/usr/lib/python3.5/site-packages/systemd_coredump_exception_handler.py", line 162, in f div0 = 1 / 0 ZeroDivisionError: division by zero
Local variables in innermost frame: h=<function f at 0x7f3eb38f3400> a=3
Zbyszek
Dne 15.3.2017 v 04:14 Zbigniew Jędrzejewski-Szmek napsal(a):
This conflict should be temporary, the patch to make the abrt handler non-exclusive should be trivial.)
Patches are welcome.
- run a python script that throws an exception e.g. python3 /usr/lib/python3.5/site-packages/systemd_coredump_exception_handler.py, this should print a traceback to stdout
Commands: will_python_raise will_python3_raise will_python_sigsegv
from package will-crash are probably more comfortable
On Wed, Mar 15, 2017 at 01:39:48PM +0100, Miroslav Suchý wrote:
Dne 15.3.2017 v 04:14 Zbigniew Jędrzejewski-Szmek napsal(a):
This conflict should be temporary, the patch to make the abrt handler non-exclusive should be trivial.)
Patches are welcome.
It's on my todo list ;)
- run a python script that throws an exception e.g. python3 /usr/lib/python3.5/site-packages/systemd_coredump_exception_handler.py, this should print a traceback to stdout
Commands: will_python_raise will_python3_raise will_python_sigsegv
Ah, cool, a very nice set of commands ;)
$ coredumpctl --since today TIME PID UID GID SIG COREFILE EXE Wed 2017-03-15 10:09:35 EDT 3270 1000 1000 - - /usr/bin/python3.5 Wed 2017-03-15 10:10:37 EDT 3362 1000 1000 - - /usr/bin/python2.7 Wed 2017-03-15 10:12:25 EDT 3514 1000 1000 11 present /usr/bin/python2.7
Zbyszek
----- Original Message -----
There's a new tiny package which provides a python traceback logging in the journal for python processes. It's very similar to the existing handler provided by abrt, it also installs itself as sys.excepthook using a .pth file, but instead of communicating with abrt, it talks to systemd-coredump directly.
If it's an upstream feature, could you please update: https://bugs.freedesktop.org/show_bug.cgi?id=82507 ?
Cheers