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 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: References: <10e3756b-5e8f-ba00-df0d-b36c93fa2281@inlv.org>, 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 , Martijn Dekker , DASH shell mailing list , busybox , Bug reports for the GNU Bourne Again SHell , Robert Elz , Jilles Tjoelker 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: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <10e3756b-5e8f-ba00-df0d-b36c93fa2281@inlv.org>, Xref: csiph.com gnu.bash.bug:15872 IMHO is the bug on bash side. ash can assume to get an "healthy" environmen= t from the caller. You can simply not fix everything that can possible go w= rong. Obviously it should not segfault but so far i understand it is bsd as that = does, not busybox ash. re, wh ________________________________________ Von: busybox 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 G= NU 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 >=3D 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 >=3D 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