From owner-freebsd-bugs@FreeBSD.ORG Wed Aug 2 00:10:15 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1F84916A4E1 for ; Wed, 2 Aug 2006 00:10:15 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0DB9B43D45 for ; Wed, 2 Aug 2006 00:10:14 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k720ADQP075618 for ; Wed, 2 Aug 2006 00:10:13 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k720AD0C075617; Wed, 2 Aug 2006 00:10:13 GMT (envelope-from gnats) Resent-Date: Wed, 2 Aug 2006 00:10:13 GMT Resent-Message-Id: <200608020010.k720AD0C075617@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Nate Eldredge Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 34B6916A4E5 for ; Wed, 2 Aug 2006 00:08:41 +0000 (UTC) (envelope-from nate@cs.hmc.edu) Received: from turing.cs.hmc.edu (turing.cs.hmc.edu [134.173.42.99]) by mx1.FreeBSD.org (Postfix) with ESMTP id D6BE943D4C for ; Wed, 2 Aug 2006 00:08:40 +0000 (GMT) (envelope-from nate@cs.hmc.edu) Received: from knuth.cs.hmc.edu (knuth.cs.hmc.edu [134.173.42.100]) by turing.cs.hmc.edu (Postfix) with ESMTP id 5411253279 for ; Tue, 1 Aug 2006 17:08:40 -0700 (PDT) Received: by knuth.cs.hmc.edu (Postfix, from userid 26983) id 45A09BF44; Tue, 1 Aug 2006 17:08:40 -0700 (PDT) Message-Id: <20060802000840.45A09BF44@knuth.cs.hmc.edu> Date: Tue, 1 Aug 2006 17:08:40 -0700 (PDT) From: Nate Eldredge To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/101232: make(1) hangs with -j and -f - (patch) X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Nate Eldredge List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Aug 2006 00:10:15 -0000 >Number: 101232 >Category: bin >Synopsis: make(1) hangs with -j and -f - (patch) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Aug 02 00:10:13 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Nate Eldredge >Release: FreeBSD 6.1-RELEASE-p1 amd64 >Organization: >Environment: System: FreeBSD vulcan.lan 6.1-RELEASE-p1 FreeBSD 6.1-RELEASE-p1 #1: Wed May 31 21:52:41 PDT 2006 nate@vulcan.lan:/usr/obj/usr/src/sys/VULCAN amd64 >Description: If you run make(1) with -j NN and reading the makefile from standard input, it hangs. >How-To-Repeat: $ cat >mf all : true ^D $ make -j 6 -f - Fix: There is a typo in job.c. Here is a patch, explanation follows. --- /usr/src/usr.bin/make/job.c Wed Jul 20 12:05:23 2005 +++ job.c Tue Aug 1 16:22:42 2006 @@ -2338,7 +2338,7 @@ jobFull = FALSE; } } - if (fifoFd <= 0) { + if (fifoFd < 0) { maxJobs = maxproc; jobFull = FALSE; } else { The bug is obvious; this section is supposed to run when the fifo could not be opened. But 0 is a valid file descriptor, so fifoFd == 0 does not indicate error. When -f - is used, make(1) reads its Makefile from standard input (file descriptor 0) and then closes it. So now fd 0 is available for reuse. It winds up getting assigned to fifoFd. Now the preceding code clobbers the value of maxproc in the case that opening the fd succeeded (which is perhaps bad style), so if this code runs as well, maxJobs gets set to a bogus value (-1) and things go haywire. >Release-Note: >Audit-Trail: >Unformatted: