NetBSD Problem Report #49092

From jarmo.jaakkola@roskakori.fi  Fri Aug  8 21:34:51 2014
Return-Path: <jarmo.jaakkola@roskakori.fi>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id B9136A8857
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  8 Aug 2014 21:34:51 +0000 (UTC)
Message-Id: <20140808213446.6D3D05312@roskakori.fi>
Date: Sat,  9 Aug 2014 00:34:46 +0300 (EEST)
From: Jarmo Jaakkola <jarmo.jaakkola@roskakori.fi>
Reply-To: Jarmo Jaakkola <jarmo.jaakkola@roskakori.fi>
To: gnats-bugs@gnats.NetBSD.org
Subject: make(1): output ordering changes when stdout is a file or pipe
X-Send-Pr-Version: 3.95

>Number:         49092
>Category:       toolchain
>Synopsis:       make(1): output is not properly flushed after a failure is ignored
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Aug 08 21:35:00 +0000 2014
>Last-Modified:  Sat Aug 23 14:55:01 +0000 2014
>Originator:     Jarmo Jaakkola <jarmo.jaakkola@roskakori.fi>
>Release:        NetBSD 6.1.2_PATCH
>Organization:
>Environment:
System: NetBSD kotoisa.roskakori.fi 6.1.2_PATCH NetBSD 6.1.2_PATCH (KOTOISA) #5: Mon Jan 20 17:01:44 EET 2014 jammuli@kotoisa.roskakori.fi:/usr/src/sys/arch/amd64/compile/KOTOISA amd64
Architecture: x86_64
Machine: amd64
>Description:
When make is invoked with -k, a message about an ignored command failure
is output only after output from the next command has been printed if
stdout is a file or a pipe.  I'd assume this occurs because stdout is
line buffered if it is associated with terminal and block buffered otherwise.
The message being newline terminated and printing fine on terminal certainly
suggests that.
>How-To-Repeat:
$ cat >Makefile <<EOF
all: first second
first:
	@echo 'Next line should be: "*** Error code 1 (continuing)"'
	@false
second:
	@echo "Next line should be: \"\`all' not remade because of errors.\""
EOF

$ make -k
Next line should be: "*** Error code 1 (continuing)"
*** Error code 1 (continuing)
Next line should be: "`all' not remade because of errors."
`all' not remade because of errors.

$ make -k >log; cat log
Next line should be: "*** Error code 1 (continuing)"
Next line should be: "`all' not remade because of errors."
*** Error code 1 (continuing)
`all' not remade because of errors.

$ make -k | cat
Next line should be: "*** Error code 1 (continuing)"
Next line should be: "`all' not remade because of errors."
*** Error code 1 (continuing)
`all' not remade because of errors.
>Fix:
If stdout is flushed after the error message, the output is in correct
order.  Would it make sense to explicitly set the buffering strategy
on stdout in case there are other problems like this?  Anyway, here's
where you would do the flush.

--- usr.bin/make/compat.c.old
+++ usr.bin/make/compat.c
@@ -475,6 +475,7 @@
 		    status = 0;
 		}
 	    }
+	    fflush(stdout);
 	    break;
 	} else {
 	    Fatal("error in wait: %d: %s", retstat, strerror(errno));

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/49092 CVS commit: src
Date: Sat, 23 Aug 2014 10:50:24 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Sat Aug 23 14:50:24 UTC 2014

 Modified Files:
 	src/tests/usr.bin/make: t_make.sh
 	src/usr.bin/make: make.1 parse.c var.c
 Added Files:
 	src/tests/usr.bin/make: d_posix.mk d_posix.out

 Log Message:
 PR/49085: Jarmo Jaakkola: fix several parsing errors

 Don't exit from var.c:Var_Parse() before possible modifiers are handled
 on D and F modified versions of local variables.  Properly expand $(?D)
 and $(?F) too.

 Make line continuations in rule's commands POSIX compliant.

 Fix the syntax error caused by lib(member) as the last target before
 a dependency operator.

 Document the line continuation change in the manual page.  Also talk
 more about the POSIX style local variables and their modifiers.

 Add tests covering the fixed problems into d_posix.mk.  The test is
 a known failure at the moment because of PR 49086 and PR 49092.

 [XXX: unconverted tests]


 To generate a diff of this commit:
 cvs rdiff -u -r0 -r1.3 src/tests/usr.bin/make/d_posix.mk \
     src/tests/usr.bin/make/d_posix.out
 cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/make/t_make.sh
 cvs rdiff -u -r1.230 -r1.231 src/usr.bin/make/make.1
 cvs rdiff -u -r1.198 -r1.199 src/usr.bin/make/parse.c
 cvs rdiff -u -r1.186 -r1.187 src/usr.bin/make/var.c

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

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.