Repository navigation
Description
Summary
An rsync daemon remained alive indefinitely after SIGTERM was sent to its process group.
The captured GDB backtrace appears to show a signal-handler reentrancy deadlock: normal execution was inside __tz_convert(), and the signal-handling path called syslog(), which re-entered __tz_convert() through localtime_r() and blocked on the timezone lock.
This was observed with rsync 3.1.1. I have not yet reproduced it with a current release, and I do not have a deterministic reproducer.
Environment
- Ubuntu 16.04.4 LTS, x86-64
- Kernel: 4.9.70-040970-generic
- rsync: 3.1.1-3ubuntu1.2
- glibc: 2.23-0ubuntu11.3
The executable used by the stuck process was confirmed to be this rsync version.
Observed scenario
We start a daemon using a command equivalent to:
rsync --daemon --config=/path/to/rsync/rsync.conf --port=12345The generated configuration follows this structure, with internal paths and the module name replaced:
use chroot = no
pid file = /path/to/rsync/rsync.pid
list = no
exclude = rsync.* index_db
[testmodule]
path = /path/to/rsync
read only = yesNo explicit log file is configured.
When our Python application attempts to stop the rsync daemon, it reads the daemon PID from the PID file and sends SIGTERM to its process group:
os.killpg(pid, signal.SIGTERM)Expected behavior
The daemon should exit after receiving SIGTERM.
Actual behavior
The daemon remained alive for weeks in a sleeping state, with PPID 1. Subsequent SIGTERM delivery did not cause it to exit.
Process state and signal masks
Collected using:
$ sudo grep -E '^(State|SigPnd|ShdPnd|SigBlk|SigIgn|SigCgt):' /proc/81658/statusOutput:
State: S (sleeping)
SigPnd: 0000000000000000
ShdPnd: 0000000000004000
SigBlk: 0000000000004000
SigIgn: 0000000001001a00
SigCgt: 0000000000014003
GDB backtrace
Collected using:
sudo gdb -q -nx -batch \
-ex "set pagination off" \
-ex "thread apply all bt" \
-ex "detach" \
-p 81658Output:
Thread 1 (process 81658):
#0 __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
#1 0x00007fe8f93e1cf6 in __tz_convert (timer=0x7fe8f96eaac0 <tzset_lock>, timer@entry=0x7ffc3c7187d8, use_localtime=use_localtime@entry=1, tp=tp@entry=0x7ffc3c718830) at tzset.c:616
#2 0x00007fe8f93df9ad in __localtime_r (t=t@entry=0x7ffc3c7187d8, tp=tp@entry=0x7ffc3c718830) at localtime.c:30
#3 0x00007fe8f942477d in __GI___vsyslog_chk (pri=<optimized out>, flag=1, fmt=0x560d633fbce7 "%s", ap=0x7ffc3c7188b8) at ../misc/syslog.c:199
#4 0x00007fe8f9424ce2 in __syslog_chk (pri=<optimized out>, flag=<optimized out>, fmt=<optimized out>) at ../misc/syslog.c:129
#5 0x0000560d633cc19f in ?? ()
#6 0x0000560d633cc3d4 in ?? ()
#7 0x0000560d633bf9ab in ?? ()
#8 0x0000560d633b6b1f in ?? ()
#9 <signal handler called>
#10 _IO_vfscanf_internal (s=s@entry=0x7ffc3c71bb50, format=format@entry=0x7fe8f94b2255 "%hu%n:%hu%n:%hu%n", argptr=argptr@entry=0x7ffc3c71bc78, errp=errp@entry=0x0) at vfscanf.c:637
#11 0x00007fe8f9394287 in _IO_vsscanf (string=0x560d638517bc "8", format=0x7fe8f94b2255 "%hu%n:%hu%n:%hu%n", args=args@entry=0x7ffc3c71bc78) at iovsscanf.c:41
#12 0x00007fe8f938e927 in __sscanf (s=s@entry=0x560d638517bc "8", format=format@entry=0x7fe8f94b2255 "%hu%n:%hu%n:%hu%n") at sscanf.c:32
#13 0x00007fe8f93e0dde in parse_offset (whichrule=0, tzp=0x7ffc3c71bd68) at tzset.c:236
#14 __tzset_parse_tz (tz=0x560d638517bc "8") at tzset.c:357
#15 0x00007fe8f93e34b8 in __tzfile_compute (timer=1791773377, use_localtime=use_localtime@entry=1, leap_correct=leap_correct@entry=0x7ffc3c71be28, leap_hit=leap_hit@entry=0x7ffc3c71be24, tp=tp@entry=0x7fe8f96ed4a0 <_tmbuf>) at tzfile.c:691
#16 0x00007fe8f93e1dff in __tz_convert (timer=0x7ffc3c71be68, use_localtime=1, tp=0x7fe8f96ed4a0 <_tmbuf>) at tzset.c:624
#17 0x0000560d633c6293 in ?? ()
#18 0x0000560d633cbb21 in ?? ()
#19 0x0000560d633ec0e2 in ?? ()
#20 0x0000560d633ac355 in ?? ()
#21 0x00007fe8f9344840 in __libc_start_main (main=0x560d633ab9b0, argc=4, argv=0x7ffc3c71efe8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffc3c71efd8) at ../csu/libc-start.c:291
#22 0x0000560d633acc89 in ?? ()
Suspected cause
My interpretation of the backtrace is:
| Frames | Event |
|---|---|
#16 |
Normal execution is inside __tz_convert(), apparently within the section protected by tzset_lock. |
#15–#10 |
Timezone computation continues while holding tzset_lock. |
#9 |
Control transfers to a signal handler while the interrupted call has not returned. |
#8–#2 |
The signal-handling path calls syslog(), which calls localtime_r(). |
#1–#0 |
The nested __tz_convert() call waits for the lock held by the interrupted execution. |
This appears to be a self-deadlock: the handler cannot return until it acquires the lock, while the interrupted execution cannot release the lock until the handler returns.
SIGTERM is the likely triggering signal given the os.killpg call and signal masks, but the captured stack does not directly establish the signal number or sender. The rsync frames lack debug symbols.
Existing issues reviewed
I reviewed the results of searches for deadlock, tz_convert, tzset, syslog, and localtime, but did not find a matching report.
The closest-looking reports appear to describe different problems:
- Wrong timing in rsync daemon log #729: incorrect log timestamps after chroot; this daemon uses
use chroot = no. - "rsync -avv /src/ /dst/" hangs constantly at the same place #159 and Network I/O deadlock #257: I/O buffering deadlocks.
- rsync 3.2.1-1 crashes on Debian bullseye/sid (testing) #43: a daemon crash related to the default log format.
Question
Is this a known signal-handling issue, and has it been addressed in a later release?
I understand that 3.1.1 is an old version. Any pointer to a relevant fix or guidance on reproducing and diagnosing this on a current version would be appreciated.
Thank you for maintaining rsync.
Activity
steadytao commentedon Nov 6, 2026
Ah #1129 fixed the buffer flush but we can still call syslog from the signal handler. We need to move cleanup out of the handler and wake the daemon loop to finish shutting down.