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


Groups > gnu.bash.bug > #15869

Re: Bizarre interaction bug involving bash w/ lastpipe + Almquist 'wait'

Path csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Harald van Dijk <harald@gigawatt.nl>
Newsgroups gnu.bash.bug
Subject Re: Bizarre interaction bug involving bash w/ lastpipe + Almquist 'wait'
Date Thu, 6 Feb 2020 19:29:41 +0000
Lines 51
Approved bug-bash@gnu.org
Message-ID <mailman.390.1581022060.2412.bug-bash@gnu.org> (permalink)
References <10e3756b-5e8f-ba00-df0d-b36c93fa2281@inlv.org> <f8b210f5-dd59-2c7f-05d4-be0a89316d3d@gigawatt.nl>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding quoted-printable
X-Trace usenet.stanford.edu 1581022061 13456 209.51.188.17 (6 Feb 2020 20:47:41 GMT)
X-Complaints-To action@cs.stanford.edu
To Martijn Dekker <martijn@inlv.org>, DASH shell mailing list <dash@vger.kernel.org>, busybox <busybox@busybox.net>, Bug reports for the GNU Bourne Again SHell <bug-bash@gnu.org>, Robert Elz <kre@munnari.OZ.AU>, Jilles Tjoelker <jilles@stack.nl>
Envelope-to bug-bash@gnu.org
DKIM-Filter OpenDKIM Filter v2.11.0 mail.gigawatt.nl D983EC80
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gigawatt.nl; s=default; t=1581017472; bh=z0AsFWtGv5aHhM+JXjEm9LmaIwdhOACmPWL9qX1xpH8=; l=1586; h=Subject:To:References:From:Date:In-Reply-To:From; b=Y36IJAZGHeE69UQSGceOCXuN6IA+z7uk1avkKVbQw5c9jv8PTqlR9MH3MUAVHyq85 6C7ZcvFVgCVjY53z34m1bi6etpDVBkGEBiW0tKq716wYvEJlBNMlXCqAwcg9CeNf4P GW/bviBHGwMuh1nsqdLxNYssLUczEruDzX2PbyWE=
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:73.0) Gecko/20100101 Thunderbird/73.0
In-Reply-To <10e3756b-5e8f-ba00-df0d-b36c93fa2281@inlv.org>
Content-Language en-US
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From 2001:41d0:801:2000::19e9
X-Mailman-Approved-At Thu, 06 Feb 2020 15:47:39 -0500
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <f8b210f5-dd59-2c7f-05d4-be0a89316d3d@gigawatt.nl>
X-Mailman-Original-References <10e3756b-5e8f-ba00-df0d-b36c93fa2281@inlv.org>
Xref csiph.com gnu.bash.bug:15869

Show key headers only | View raw


On 06/02/2020 16:12, Martijn Dekker wrote:
> This is probably the strangest bug (or maybe pair of bugs) I've run into 
> in nearly five years of breaking shells by developing modernish.
> 
> I've traced it to an interaction between bash >= 4.2 (i.e.: bash with 
> shopt -s lastpipe) and variants of the Almquist shell, at least: dash, 
> gwsh, Busybox ash, FreeBSD sh, and NetBSD 9.0rc2 sh.
> 
> Symptom: if 'return' is invoked on bash in the last element of a pipe 
> executed in the main shell environment, then if you subsequently 'exec' 
> an Almquist shell variant so that it has the same PID, its 'wait' 
> builtin breaks.
> 
> I can consistently reproduce this on Linux, macOS, FreeBSD, NetBSD 
> 9.0rc2, OpenBSD, and Solaris.
> 
> To reproduce this, you need bash >= 4.2, some Almquist shell variant, 
> and these two test scripts:
> 
> ---begin test.bash---
> fn() {
>      : | return
> }
> shopt -s lastpipe || exit
> fn
> exec "${1:-dash}" test.ash
> ---end test.bash---
> 
> ---begin test.ash---
> echo '*ash-begin'
> : &
> echo '*ash-middle'
> wait "$!"
> echo '*ash-end'
> ---end test.ash---
> 
> When executing test.bash with dash, gwsh, Busybox ash, or FreeBSD sh, 
> then test.ash simply waits forever on executing 'wait "$!"'.

Nice test. bash leaves the process in a state where SIGCHLD is blocked, 
and the various ash-based shells do not unblock it. Because of that, 
they do not pick up on the fact that the child process has terminated. I 
would consider this a bug both in bash and in the ash-based shells.

Cheers,
Harald van Dijk

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: Bizarre interaction bug involving bash w/ lastpipe + Almquist 'wait' Harald van Dijk <harald@gigawatt.nl> - 2020-02-06 19:29 +0000

csiph-web