Bug 128274 - bash reports "broken pipe" erroneously
bash reports "broken pipe" erroneously
Status: CLOSED WONTFIX
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: bash (Show other bugs)
3.0
x86_64 Linux
medium Severity medium
: ---
: ---
Assigned To: Tomas Janousek
Ben Levenson
: Regression, Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-07-20 21:06 EDT by Alan Sparks
Modified: 2010-07-22 09:32 EDT (History)
2 users (show)

See Also:
Fixed In Version: 2.05b-44
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-12-20 11:08:11 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
test data (165.86 KB, text/plain)
2004-07-20 21:08 EDT, Alan Sparks
no flags Details
Requested strace output (86.93 KB, text/plain)
2004-07-21 11:38 EDT, Alan Sparks
no flags Details

  None (edit)
Description Alan Sparks 2004-07-20 21:06:53 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7)
Gecko/20040626 Firefox/0.8 StumbleUpon/1.904

Description of problem:
bash pipes fail apparently if close to 4096 bytes of data flows
through the pipe.  Or something like that.  Random 'broken pipe'
messages occur if the following procedure is followed.



Version-Release number of selected component (if applicable):
bash-2.05b-29

How reproducible:
Always

Steps to Reproduce:
1. Use the attached data file (mq.txt).
2. create an executable script (foo.sh) with the following:

cat mq.txt | head -922 \
        | perl -n -e '/^\s+\<.*\@(.*)\>/ && print "$1\n"' \
        | sort \
        | uniq -c \
        | sort -nr

3. Run script.  Note a few lines, no errors.
4.Vary the number in the first "head" to -923 and -924, rerun program.
 You will note that with -923 up, you will sporadically get "broken
pipe" messages from the shell.

    

Actual Results:  $ ./foo.sh |head
      5 hotamil.com
      4 hotmail.
      4 belsouth.net
      4 aol.comy
      3 verison.net
      2 yahoo.comm
      2 yahoo.
      2 us.army.mail
      2 pipersoftware.net
      2 earhtlink.net
./foo.sh: line 5:  2252 Broken pipe             cat mq.txt
      2253 Done                    | head -925
      2254 Done                    | perl -n -e '/^\s+\<.*\@(.*)\>/ &&
print "$1\n"'
      2255 Done                    | sort
      2256 Done                    | uniq -c
      2257                       | sort -nr

Expected Results:  $ ./foo.sh |head
      5 hotamil.com
      4 hotmail.
      4 belsouth.net
      4 aol.comy
      3 verison.net
      2 yahoo.comm
      2 yahoo.
      2 us.army.mail
      2 pipersoftware.net
      2 earhtlink.net
[asparks@stampy asparks]$

Additional info:
Comment 1 Alan Sparks 2004-07-20 21:08:57 EDT
Created attachment 102092 [details]
test data
Comment 2 Tim Waugh 2004-07-21 09:47:34 EDT
Please attach the output of 'strace -f bash ./foo.sh >/dev/null' for a
run that gives a broken pipe error.
Comment 3 Alan Sparks 2004-07-21 11:38:59 EDT
Created attachment 102108 [details]
Requested strace output

This is tweaky, since the main failure mode is when the foo.sh output is
redirected into a program that may terminate early (thus creating the potential
"broken pipe" circumstance.  I've run the command:
(strace -f bash ./foo.sh |head) >trace.out 2>&1
and included a run that shows the broken pipe output.  I note that the same
sporadic behavior occurs here too, sometimes the run will NOT throw a sigpipe.
Comment 4 Tim Waugh 2004-07-21 12:55:10 EDT
Here is a simpler test case:

echo 'for x in $(seq 1 2500); do echo $x; done' > test1.sh
echo 'for x in $(seq 1 2500); do echo $x; done | cat' > test2.sh
bash ./test1.sh | head -n 1 # no error
bash ./test2.sh | head -n 1 # broken pipe

This behaviour is configurable, and I have disabled SIGPIPE error
reporting in Fedora development.  This change will appear in a future
release of Red Hat Enterprise Linux.
Comment 9 Chris Ward 2007-12-12 10:52:42 EST
When running the given test case, 

echo 'for x in $(seq 1 2500); do echo $x; done' > test1.sh
echo 'for x in $(seq 1 2500); do echo $x; done | cat' > test2.sh
bash ./test1.sh | head -n 1 # no error
bash ./test2.sh | head -n 1 # broken pipe

Bash still returns error about a broken pipe.

%> rpm -q bash 
bash-2.05b-41.7.i386

%> rpm -q --whatprovides /etc/redhat-release 
redhat-release-3AS-13.9.5.i386

RHTS available, /CoreOS/bash/builtins/broken-pipe-bz128274
Comment 10 Tomas Janousek 2007-12-20 11:08:11 EST
The fix for this has never been committed to RHEL-3. Therefore, it's not a
regression and there's no way we can convince PM to let us fix it (not that I
consider that worthwhile).

Note You need to log in before you can comment on or make changes to this bug.