[PATCH] Infinite recursion in rsync --server

Aaron Hopkins aaron at die.net
Sat Jul 6 16:22:01 EST 2002


-----BEGIN PGP SIGNED MESSAGE-----

With rsync --server, sometimes when the remote side control-C's a transfer,
rsync will immediately start consuming all available RAM.

gdb shows that its recursing while trying to report the failed write:

    #0  0x420503ac in vfprintf () from /lib/i686/libc.so.6
    #1  0x42072f74 in vsnprintf () from /lib/i686/libc.so.6
    #2  0x08052ca4 in rprintf (code=FERROR, 
        format=0x8068a00 "rsync error: %s (code %d) at %s(%d)\n") at log.c:295
    #3  0x080532b5 in log_exit (code=13, file=0x806878f "log.c", line=279)
        at log.c:564
    #4  0x0804c9ad in _exit_cleanup (code=13, file=0x806878f "log.c", line=279)
        at cleanup.c:87
    #5  0x08052c4e in rwrite (code=FERROR, 
        buf=0xb1da4bf0 "rsync error: errors with program diagnostics (code 13) at log.c(279)\n", len=69) at log.c:279
    #6  0x08052d12 in rprintf (code=FERROR, 
        format=0x8068a00 "rsync error: %s (code %d) at %s(%d)\n") at log.c:324
    #7  0x080532b5 in log_exit (code=13, file=0x806878f "log.c", line=279)
        at log.c:564
    #8  0x0804c9ad in _exit_cleanup (code=13, file=0x806878f "log.c", line=279)
        at cleanup.c:87
    #9  0x08052c4e in rwrite (code=FERROR, 
        buf=0xb1da50b0 "rsync error: errors with program diagnostics (code 13) at log.c(279)\n", len=69) at log.c:279
    #10 0x08052d12 in rprintf (code=FERROR, 
        format=0x8068a00 "rsync error: %s (code %d) at %s(%d)\n") at log.c:324
    [...]
    #8442 0x08052d12 in rprintf (code=FERROR, 
        format=0x8068a00 "rsync error: %s (code %d) at %s(%d)\n") at log.c:324
    [...]

This continues until the server kills the out-of-control process due to lack
of memory, obviously making everything else on the server unhappy for a
while in the process.

rwrite () knows about this possible recursion, but only handles it properly
with "am_daemon".

This bug is present in at least 2.5.4 and 2.5.5.  The simple attached patch
fixes this, and patches cleanly against either.

If for some reason the MIME gets eaten, you can also pick it up from:

    https://www.die.net/tmp/50dff5d6fd24afd8e731eb2fa3f86556/rsync-2.5.4-oom.patch

                                    -- Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)

iQCVAwUBPSd7WEfJWHAEvsjBAQGgzwP9FYgef+GQxrDDRcSr3or5o2t89xNKoaiT
TE2A0NI3OXvYBNxrMVPXfXIXRrM/fUSinPGuFGV5vldBwbBuhU3uEEs55o46LVeX
IE6arHUyvqWWg4+ScvtWwVMVTpx8oYvZzWfxye/NV5hNuyi4AdktvDzehBAXqlwJ
zyip6eWMDbI=
=3y2w
-----END PGP SIGNATURE-----
-------------- next part --------------
--- rsync-2.5.4/log.c~	Sat Jul  6 15:47:32 2002
+++ rsync-2.5.4/log.c	Sat Jul  6 15:47:32 2002
@@ -246,7 +246,7 @@
 		return;
 	}
 
-	if (am_daemon) {
+	if (am_daemon || am_server) {
 		static int depth;
 		int priority = LOG_INFO;
 		if (code == FERROR) priority = LOG_WARNING;


More information about the rsync mailing list