Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15020 > unrolled thread

Re: FIFO race condition on SunOS kernels

Started byChet Ramey <chet.ramey@case.edu>
First post2018-12-31 14:05 -0500
Last post2018-12-31 14:05 -0500
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: FIFO race condition on SunOS kernels Chet Ramey <chet.ramey@case.edu> - 2018-12-31 14:05 -0500

#15020 — Re: FIFO race condition on SunOS kernels

FromChet Ramey <chet.ramey@case.edu>
Date2018-12-31 14:05 -0500
SubjectRe: FIFO race condition on SunOS kernels
Message-ID<mailman.6636.1546283127.1284.bug-bash@gnu.org>
On 12/31/18 12:37 PM, Martijn Dekker wrote:
> You'd think that establishing a pipe between two processes is a very basic
> UNIX feature that should work reliably on all UNIX variants.
> 
> But the following script seems to break consistently on Solaris and
> variants (SunOS kernels) when executed by bash, ksh93, or dash. All it does
> is make 100 FIFOs and read a line from each -- it should be trivial.
> 
> And it does work fine on (recent versions of) Linux, macOS, and all the
> BSDs, on all shells.
> 
> #! /bin/sh
> tmpdir=/tmp/FIFOs$$
> trap "exec rm -rf $tmpdir" EXIT INT PIPE TERM
> mkdir "$tmpdir" || exit
> i=0; while test "$((i+=1))" -le 100; do
>         fifo=$tmpdir/FIFO$i
>         mkfifo "$fifo" || exit
>         echo "this is FIFO $i" >"$fifo" &
>         read foo <"$fifo" && echo "$foo"
> done
> 
> Tested on Solaris 10.1, 11.3 and 11.4 and on OpenIndiana, all on
> VirtualBox. They all fail in identical ways.
> 
> ksh93 (which is /bin/sh on Solaris) doesn't cope with the script either but
> hangs slightly later. dash goes through all of them bust most fail with
> 'interrupted system call'. However, zsh, yash, and /usr/xpg4/bin/sh (ksh88)
> execute the script correctly on Solaris -- but about 20 times as slowly as
> on other OSs.
> 
> This makes me suspect the SunOS kernel must have some very bad race
> condition involving FIFOs, but some shells work around it.
> 
> Would it be possible to fix this on bash 5?

Maybe as a patch, when I have some time to investigate it.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web