Bug#627025: perl: data loss in output when both stdout and stderr are redirected to a pipe

Vincent Lefevre vincent at vinc17.net
Tue May 17 03:03:18 UTC 2011


Package: perl
Version: 5.12.3-6
Severity: grave
Justification: causes non-serious data loss

When stdout and stderr are both redirected to a pipe, some of the
output data can be lost!

I can reproduce this bug with:

------------------------------------------------------------
#!/usr/bin/env perl

use strict;
use SVN::Client;

my $ctx = new SVN::Client;
$ctx->log(\@ARGV, 'HEAD', 1, 0, undef, \&log_receiver);

sub log_receiver
  {
    print "@_[0..4]\n";
  }
------------------------------------------------------------

For instance, with a large local repository:

xvii% ./svn2log wd 2>&1 | cat >| out; ls -l out
-rw-r--r-- 1 vinc17 vinc17 5398648 2011-05-17 04:45:57 out
xvii% ./svn2log wd 2>&1 | cat >| out; ls -l out
-rw-r--r-- 1 vinc17 vinc17 3993720 2011-05-17 04:45:59 out
xvii% ./svn2log wd 2>&1 | cat >| out; ls -l out
-rw-r--r-- 1 vinc17 vinc17 5398648 2011-05-17 04:46:02 out
xvii% ./svn2log wd 2>&1 | cat >| out; ls -l out
-rw-r--r-- 1 vinc17 vinc17 5398648 2011-05-17 04:46:05 out
xvii% ./svn2log wd 2>&1 | cat >| out; ls -l out
-rw-r--r-- 1 vinc17 vinc17 5398648 2011-05-17 04:46:07 out
xvii% ./svn2log wd 2>&1 | cat >| out; ls -l out
-rw-r--r-- 1 vinc17 vinc17 5398648 2011-05-17 04:46:09 out
xvii% ./svn2log wd 2>&1 | cat >| out; ls -l out
-rw-r--r-- 1 vinc17 vinc17 5398648 2011-05-17 04:46:12 out
xvii% ./svn2log wd 2>&1 | cat >| out; ls -l out
-rw-r--r-- 1 vinc17 vinc17 4943992 2011-05-17 04:46:14 out

The shell doesn't matter: same problem with zsh, bash and dash.
The problem is even more visible when using "less".

  ./svn2log wd 2>&1 | less -M

then type [End]. The number of lines changes each time.

I couldn't reproduce the problem with a remote repository,
perhaps because of some race condition that occurs when one
gets data much faster.

The problem doesn't occur if I don't redirect stderr.

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.38-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=POSIX, LC_CTYPE=en_US.ISO8859-1 (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/dash

Versions of packages perl depends on:
ii  libbz2-1.0              1.0.5-6          high-quality block-sorting file co
ii  libc6                   2.13-4           Embedded GNU C Library: Shared lib
ii  libdb5.1                5.1.25-10        Berkeley v5.1 Database Libraries [
ii  libgdbm3                1.8.3-9          GNU dbm database routines (runtime
ii  perl-base               5.12.3-6         minimal Perl system
ii  perl-modules            5.12.3-6         Core Perl modules
ii  zlib1g                  1:1.2.3.4.dfsg-3 compression library - runtime

Versions of packages perl recommends:
ii  netbase                       4.45       Basic TCP/IP networking system

Versions of packages perl suggests:
ii  libterm-readline-gnu-perl     1.20-1+b1  Perl extension for the GNU ReadLin
ii  make                          3.81-8.1   An utility for Directing compilati
ii  perl-doc                      5.12.3-6   Perl documentation

-- no debconf information






More information about the Perl-maintainers mailing list