bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash incorrectly handles 'echo' + SIGPIPE under some situations on L


From: Piotr Grzybowski
Subject: Re: bash incorrectly handles 'echo' + SIGPIPE under some situations on Linux
Date: Tue, 5 Jan 2016 19:29:58 +0100

hello,

 I cannot reproduce it in anyway on mac os x86_64 with any version
after 4.2, but I see your output on i686 linux with 4.3 and 4.4. Seems
system dependent, and also: it is enough to change line 10 to:

/bin/echo final

or

stdbuf -o0 -i0 -e0 echo final

to get expected results. I wonder if calling fflush(0); somewhere in
echo builtin will not fix this?
 As for https://github.com/golang/go/issues/13789 and removal of the
repository: running code like:

rm -rf pkg $(go env GOROOT)/${installdir}

is a oneway ticket to oblivion no matter what. Never do that. Check
four times, that the directory you are removing with rm -rf existst,
and that it is what you really want to delete, also use "" so next
time you get output: '/ ok' you do not wipe your everything.

cheers,
pg



On Tue, Jan 5, 2016 at 5:47 PM,  <cks@cs.toronto.edu> wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' 
> -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
> -DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib  -D_FORTIFY_SOURCE=2 
> -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat 
> -Werror=format-security -Wall
> uname output: Linux apps0 3.13.0-65-generic #106-Ubuntu SMP Fri Oct 2 
> 22:08:27 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
> Machine Type: x86_64-pc-linux-gnu
>
> Bash Version: 4.3
> Patch Level: 11
> Release Status: release
>
> Description:
>
> If Bash writes to stdout with the built in echo and gets a SIGPIPE,
> it can incorrectly buffer and then repeat this would-have-been output
> in at least $(...) things invoked in a cleanup function and in fact
> in some other contexts as well. To see this in action, create the
> following script as /tmp/repro:
>
>         #!/bin/bash
>         function cleanup() {
>                 r1=$(/bin/echo one)
>                 r2=$(/bin/echo two)
>                 echo $r1 '!' $r2 1>&2
>                 #echo $r1 '!' $r2 >>/tmp/logout
>         }
>         trap cleanup EXIT
>         sleep 1
>         echo final
>
> Run it as '/tmp/repro | false'. The output produced is the clearly
> incorrect:
>         $ /tmp/repro | false
>         final
>         one final ! two final
>
> If you switch the 'echo' to the commented out version, the bare 'final'
> disappears but the other two remain.
>
> Although I am filing this bug report from an Ubuntu 14.04 LTS machine,
> this issue also reproduces with the Fedora 22 and Fedora 23 versions
> of 'version 4.3.42(1)-release' and probably on other versions as well.
>
> For your potential reference, the original issue that uncovered this
> problem is covered here:
>         https://github.com/golang/go/issues/13789
>
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]