NetBSD Problem Report #48729

From www@NetBSD.org  Wed Apr  9 11:33:46 2014
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 42891A580D
	for <gnats-bugs@gnats.NetBSD.org>; Wed,  9 Apr 2014 11:33:46 +0000 (UTC)
Message-Id: <20140409113345.1D5DFA5814@mollari.NetBSD.org>
Date: Wed,  9 Apr 2014 11:33:45 +0000 (UTC)
From: tg@gmplib.org.dontsendmailthere
Reply-To: tg@gmplib.org.dontsendmailthere
To: gnats-bugs@NetBSD.org
Subject: Bug with /bin/sh and its 'wait'
X-Send-Pr-Version: www-1.0

>Number:         48729
>Category:       bin
>Synopsis:       Bug with /bin/sh and its 'wait'
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Apr 09 11:35:00 +0000 2014
>Closed-Date:    Sat Dec 27 23:36:22 +0000 2014
>Last-Modified:  Sat Dec 27 23:36:22 +0000 2014
>Originator:     Torbjörn Granlund
>Release:        6.1.3
>Organization:
>Environment:
NetBSD tigris.csc.kth.se 6.1.3 NetBSD 6.1.3 (XEN3_DOM0) #0: Mon Feb 24 18:44:10 CET 2014  root@tigris.csc.kth.se:/usr/src/sys/arch/amd64/compile/XEN3_DOM0 amd64

>Description:
The shell builtin command 'wait' is documented to return
the exit status of the waited-for command when 'wait' is
given a pid.

It does not, at least not under all circumstances.
>How-To-Repeat:
#! /bin/sh

sleep 9999 &
pid=$!

(sleep 2; kill -9 $pid) &

wait $pid
stat=$?

echo "This should be 137:" $stat

>Fix:
My workaround is to use bash, or run the needed scripts under
another *BSD.

>Release-Note:

>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/48729: Bug with /bin/sh and its 'wait'
Date: Wed, 9 Apr 2014 14:20:30 +0200

 This still fails in -current

 Martin

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48729 CVS commit: src/bin/sh
Date: Thu, 10 Apr 2014 21:49:45 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Fri Apr 11 01:49:45 UTC 2014

 Modified Files:
 	src/bin/sh: jobs.c

 Log Message:
 PR/48729: Torbjörn Granlund: Avoid negative index in array ref.


 To generate a diff of this commit:
 cvs rdiff -u -r1.72 -r1.73 src/bin/sh/jobs.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Mon, 21 Apr 2014 01:42:14 +0000
State-Changed-Why:
Does this change fix the problem?
(you can get it on -6 by doing cvs update -j1.72 -j1.73 jobs.c, then
recompiling sh)


From: tg@gmplib.org.dontsendmailthere (=?utf-8?Q?Torbj=C3=B6rn?= Granlund)
To: gnats-bugs@gnats.netbsd.org
Cc: 
Subject: Re: bin/48729
Date: Thu, 06 Nov 2014 18:31:15 +0100

 This bug, reported and supposedly fixed in April, is still present in
 6.1.5, released in October.

 The bug seems to be fixed in a 7.0 prerelease.

 Malfunction in a fundamental shell function like wait seems to deserve
 to be put in all past maintained relesases.

 --=20
 Torbj=C3=B6rn
 Please encrypt, key id 0xC8601622

State-Changed-From-To: feedback->pending-pullups
State-Changed-By: spz@NetBSD.org
State-Changed-When: Fri, 05 Dec 2014 09:00:10 +0000
State-Changed-Why:
feedback was provided


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48729 CVS commit: [netbsd-6] src/bin/sh
Date: Sun, 7 Dec 2014 15:58:27 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sun Dec  7 15:58:27 UTC 2014

 Modified Files:
 	src/bin/sh [netbsd-6]: jobs.c

 Log Message:
 Pullup the following revisions, requested by spz in #1205:
 src/bin/sh/jobs.c	1.73

 PR/48729: Torbjörn Granlund: Avoid negative index in array ref.


 To generate a diff of this commit:
 cvs rdiff -u -r1.69 -r1.69.4.1 src/bin/sh/jobs.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/48729
Date: Sat, 27 Dec 2014 23:32:17 +0000

 On Thu, Nov 06, 2014 at 05:35:00PM +0000, Torbj?rn Granlund wrote:
  >  This bug, reported and supposedly fixed in April, is still present in
  >  6.1.5, released in October.
  >  
  >  The bug seems to be fixed in a 7.0 prerelease.
  >  
  >  Malfunction in a fundamental shell function like wait seems to deserve
  >  to be put in all past maintained relesases.

 ...we were waiting for word on whether the fix actually fixed the
 problem.

 Anyway, it's been applied to the netbsd-6 branch now. The problem does
 not exactly affect netbsd-5, plus at this point netbsd-5 is getting
 only critical/security fixes, which this is not, so I think we won't
 try to apply it there.

 (If anyone wants to, applying it also requires applying the fix for PR
 35055 and another subsequent change, versions 1.67 and 1.68 of jobs.c,
 before this change, which is version 1.73 of jobs.c.)

 -- 
 David A. Holland
 dholland@netbsd.org

State-Changed-From-To: pending-pullups->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sat, 27 Dec 2014 23:36:22 +0000
State-Changed-Why:
Pullups to -6 completed; the fix is already in -7, and we'll let -5 slide.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.