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


Groups > gnu.bash.bug > #15872

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

Path csiph.com!3.us.feeder.erje.net!feeder.erje.net!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Walter Harms <wharms@bfs.de>
Newsgroups gnu.bash.bug
Subject AW: Bizarre interaction bug involving bash w/ lastpipe + Almquist 'wait'
Date Fri, 7 Feb 2020 11:19:28 +0000
Lines 69
Approved bug-bash@gnu.org
Message-ID <mailman.427.1581074380.2412.bug-bash@gnu.org> (permalink)
References <f8b210f5-dd59-2c7f-05d4-be0a89316d3d@gigawatt.nl> <cbe5644f6db94eb89e4088141c426f8a@bfs.de>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset="iso-8859-1"
Content-Transfer-Encoding quoted-printable
X-Trace usenet.stanford.edu 1581074381 8847 209.51.188.17 (7 Feb 2020 11:19:41 GMT)
X-Complaints-To action@cs.stanford.edu
To Harald van Dijk <harald@gigawatt.nl>, 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-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=bfs.de; s=dkim201901; t=1581074369; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qegaltaw0oH4QV0mvgPdZwaZMnw3puSPBZ2l3ymyYww=; b=EEwi/bwxpPUns/0+TrB6HJkWwK2IFVbYiDYThGItTzqZZn8xKqOK1onNk/cy2TWYcGybcN C9ZTallCaaOysCWQJXPP+ONYjosno0Ht43W/brif/pb1nWjTd+2yLPDBSSDiDC9fuLOe/z i3L8Ci5pOowr2YLKGUexiHMsQ99AFA/FTxvLxK1Y7P+US2hOBWHYymyAMMDedGxVh0F049 I6zNyBkHjxFoJ4dh0r5tj5Y0r+5Ch0DJYmD3Knw9eOdYqmoBhngRbYXfW/liyvAo7XmmSU 7toSbEvjM11rLrL9y5u76lt+uRFAeqRgW5pDt1lQyHTar9YXcaxGQ/WsWgBw2w==
Thread-Topic Bizarre interaction bug involving bash w/ lastpipe + Almquist 'wait'
Thread-Index AQHV3QkxUwtODmPXUkyal7JBRH5qEqgOfLiAgAEV4zI=
In-Reply-To <f8b210f5-dd59-2c7f-05d4-be0a89316d3d@gigawatt.nl>
Accept-Language de-DE, en-US
Content-Language de-DE
X-MS-Has-Attach
X-MS-TNEF-Correlator
x-originating-ip [10.137.16.39]
Authentication-Results mx02-sz.bfs.de; none
X-Spamd-Result default: False [-0.80 / 7.00]; ARC_NA(0.00)[]; HAS_XOIP(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_ALL(0.00)[]; DKIM_SIGNED(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7]; NEURAL_HAM(-0.00)[-0.980,0]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; MID_RHS_MATCH_FROM(0.00)[]; BAYES_HAM(-0.80)[84.77%]
X-detected-operating-system by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From 194.94.69.67
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 <cbe5644f6db94eb89e4088141c426f8a@bfs.de>
X-Mailman-Original-References <10e3756b-5e8f-ba00-df0d-b36c93fa2281@inlv.org>, <f8b210f5-dd59-2c7f-05d4-be0a89316d3d@gigawatt.nl>
Xref csiph.com gnu.bash.bug:15872

Show key headers only | View raw


IMHO is the bug on bash side. ash can assume to get an "healthy" environment from the caller. You can simply not fix everything that can possible go wrong.

Obviously it should not segfault but so far i understand it is bsd as that does, not busybox ash.

re,
 wh
________________________________________
Von: busybox <busybox-bounces@busybox.net> im Auftrag von Harald van Dijk <harald@gigawatt.nl>
Gesendet: Donnerstag, 6. Februar 2020 20:29
An: Martijn Dekker; DASH shell mailing list; busybox; Bug reports for the GNU Bourne Again SHell; Robert Elz; Jilles Tjoelker
Betreff: Re: Bizarre interaction bug involving bash w/ lastpipe + Almquist 'wait'

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
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

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


Thread

AW: Bizarre interaction bug involving bash w/ lastpipe + Almquist 'wait' Walter Harms <wharms@bfs.de> - 2020-02-07 11:19 +0000

csiph-web