Skip to content

Linux kernel crashes when logging to syslog via unix socket, if rsyslog is stopped #131190

@blakehilliard

Description

@blakehilliard

Bug report

Bug description:

> uname -a
Linux hostname 6.1.124-rt16+g539895156e09 #1 SMP PREEMPT_RT Thu Feb 13 11:58:52 UTC 2025 aarch64 GNU/Linux

> cat /tmp/test.py
import logging
import logging.handlers
SYSLOG_SOCK = "/run/systemd/journal/syslog"
handler = logging.handlers.SysLogHandler(SYSLOG_SOCK)
logger = logging.getLogger()
logger.addHandler(handler)
logger.error("FIXME")

> python3 /tmp/test.py

> tail -n1 /var/log/syslog 
2025-03-13T15:37:18.047355+00:00 FIXME

> systemctl stop rsyslog syslog.socket

> strace python3 /tmp/test.py
...
socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0) = 3
connect(3, {sa_family=AF_UNIX, sun_path="/run/systemd/journal/syslog"}, 30) = -1 ECONNREFUSED (Connection refused)
close(3)                                = 0
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0) = 3
connect(3, {sa_family=AF_UNIX, sun_path="/run/systemd/journal/syslog"}, 30) = -1 ECONNREFUSED (Connection refused)
close(3)                                = 0
getpid()                                = 9214
sendto(-1, "<11>FIXME\0", 10, 0, NULL, 0

^ At this point output stops, because the linux kernel crashes

I have reproduced this with both 3.10.15 and 3.12.3 versions of python.

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-linuxpendingThe issue will be closed if no feedback is providedstdlibStandard Library Python modules in the Lib/ directory

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions