Debian Bug report logs - #28249
mawk doesn't check write errors

version graph

Package: mawk; Maintainer for mawk is Steve Langasek <vorlon@debian.org>; Source for mawk is src:mawk.

Reported by: Ian Jackson <ijackson@chiark.greenend.org.uk>

Date: Tue, 20 Oct 1998 09:48:07 UTC

Severity: normal

Merged with 4293

Found in versions 1.2.2-1, 1.3.3-2

Done: James Troup <james@nocrew.org>

Bug is archived. No further changes may be made.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, James Troup <awkmaint@nocrew.org>:
Bug#28249; Package mawk. Full text and rfc822 format available.

Acknowledgement sent to Ian Jackson <ijackson@chiark.greenend.org.uk>:
New bug report received and forwarded. Copy sent to James Troup <awkmaint@nocrew.org>. Full text and rfc822 format available.

Message #5 received at submit@bugs.debian.org (full text, mbox):

From: Ian Jackson <ijackson@chiark.greenend.org.uk>
To: Debian bugs submission address <submit@bugs.debian.org>
Subject: mawk doesn't check write errors
Date: Tue, 20 Oct 1998 10:41:41 +0100 (BST)
Package: mawk
Version: 1.3.3-2
Severity: grave

chiark:~> awk 'BEGIN { print "hi" }'
hi
chiark:~> awk 'BEGIN { print "hi" }' >/dev/full
chiark:~> echo $?
0
chiark:~> dpkg -S `type -p awk`
dpkg: /usr/bin/awk not found.
chiark:~> ll /usr/bin/awk /etc/alternatives/awk
lrwxrwxrwx   1 root     ian            13 Aug  4 10:45 /etc/alternatives/awk -> /usr/bin/mawk*
lrwxrwxrwx   1 root     root           21 Jan 24  1998 /usr/bin/awk -> /etc/alternatives/awk*
chiark:~> dpkg -S /usr/bin/mawk
mawk: /usr/bin/mawk
chiark:~> dpkg -l mawk
Desired=Unknown/Install/Remove/Purge
|
Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err:
uppercase=bad)
||/ Name            Version        Description
+++-===============-==============-============================================
ii  mawk            1.3.3-2        a pattern scanning and text processing langu
chiark:~>


Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <awkmaint@nocrew.org>:
Bug#28249; Package mawk. Full text and rfc822 format available.

Acknowledgement sent to Manoj Srivastava <srivasta@datasync.com>:
Extra info received and forwarded to list. Copy sent to James Troup <awkmaint@nocrew.org>. Full text and rfc822 format available.

Message #10 received at 28249@bugs.debian.org (full text, mbox):

From: Manoj Srivastava <srivasta@datasync.com>
To: Ian Jackson <ijackson@chiark.greenend.org.uk>, 28249@bugs.debian.org
Subject: Re: Bug#28249: mawk doesn't check write errors
Date: 20 Oct 1998 12:39:35 -0500
Hi,

	This is not a grave bug. This should be reduced to a
 wishlist. The problem does not manifest itself on a system that is
 not broken, and even then this should be the in the jurisdiction of
 the process that actually performs the redirection, namely, the
 shell. 

	There is a tradeoff between error checking and speed &
 opaqueness of the code; I think that not checking for the retirn
 value of every printf there is is acceptable.

	Please clsoe this report, or redirect it to the shell being
 used. 

	manoj

-- 
 Have a nice day!
Manoj Srivastava  <srivasta@acm.org> <http://www.datasync.com/%7Esrivasta/>
Key C7261095 fingerprint = CB D9 F4 12 68 07 E4 05  CC 2D 27 12 1D F5 E8 6E


Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <awkmaint@nocrew.org>:
Bug#28249; Package mawk. Full text and rfc822 format available.

Acknowledgement sent to Ian Jackson <ijackson@chiark.greenend.org.uk>:
Extra info received and forwarded to list. Copy sent to James Troup <awkmaint@nocrew.org>. Full text and rfc822 format available.

Message #15 received at 28249@bugs.debian.org (full text, mbox):

From: Ian Jackson <ijackson@chiark.greenend.org.uk>
To: 28249@bugs.debian.org, 28248@bugs.debian.org, 28250@bugs.debian.org, 28245@bugs.debian.org, 28251@bugs.debian.org
Cc: Manoj Srivastava <srivasta@datasync.com>
Subject: Various bugs where <foo> doesn't check write errors
Date: Wed, 21 Oct 1998 10:14:58 +0100 (BST)
I shall continue this conversation with Manoj in 28251, the bug I
filed against libc.  I suggest we leave these bugs at least open until
resolution is achieved.

Ian.


Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <awkmaint@nocrew.org>:
Bug#28249; Package mawk. Full text and rfc822 format available.

Acknowledgement sent to Chris Fearnley <cjf@i21.com>:
Extra info received and forwarded to list. Copy sent to James Troup <awkmaint@nocrew.org>. Full text and rfc822 format available.

Message #20 received at 28249@bugs.debian.org (full text, mbox):

From: Chris Fearnley <cjf@i21.com>
To: Ian Jackson <ijackson@chiark.greenend.org.uk>, 28249@bugs.debian.org
Subject: Re: Bug#28249: mawk doesn't check write errors
Date: Wed, 21 Oct 1998 13:20:17 -0400
On Tue, Oct 20, 1998 at 10:41:41AM +0100, Ian Jackson wrote:
> Package: mawk
> Version: 1.3.3-2
> Severity: grave
> 
> chiark: ~> awk 'BEGIN { print "hi" }'
> hi
> chiark:~> awk 'BEGIN { print "hi" }' >/dev/full
> chiark:~> echo $?
> 0

This is the same problem as bug #4293.

The problem, as I discussed with the upstream author at the time of #4293,
is that mawk doesn't flush it's buffers properly before closing them.
Hence unless the file is greater than 4096 bytes (on Linux - other
OSs seem to notice the problem on close and hence do not experience
this problem with mawk - it's just a peculiarity of our libc stdlib
buffering).

I apologize for not spending the time to work out a patch.  Unfortunately,
I don't have time to puzzle it out now either :(

-- 
Christopher J. Fearnley          |  Internet21 Network Engineering
cjf@i21.com                      |  Design Science Revolutionary
http://www.i21.com/~cjf          |  Explorer in Universe
ftp://ftp.netaxs.com/people/cjf  |  "Dare to be Naïve" -- Bucky Fuller


Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <awkmaint@nocrew.org>:
Bug#28249; Package mawk. Full text and rfc822 format available.

Acknowledgement sent to Manoj Srivastava <srivasta@datasync.com>:
Extra info received and forwarded to list. Copy sent to James Troup <awkmaint@nocrew.org>. Full text and rfc822 format available.

Message #25 received at 28249@bugs.debian.org (full text, mbox):

From: Manoj Srivastava <srivasta@datasync.com>
To: Dale Scheetz <dwarf@polaris.net>
Cc: 28249@bugs.debian.org, Ian Jackson <ijackson@chiark.greenend.org.uk>
Subject: Re: Bug#28249: mawk doesn't check write errors
Date: 21 Oct 1998 14:50:02 -0500
Hi,
>>"Chris" == Chris Fearnley <cjf@i21.com> writes:

 Chris> The problem, as I discussed with the upstream author at the
 Chris> time of #4293, is that mawk doesn't flush it's buffers
 Chris> properly before closing them.  Hence unless the file is
 Chris> greater than 4096 bytes (on Linux - other OSs seem to notice
 Chris> the problem on close and hence do not experience this problem
 Chris> with mawk - it's just a peculiarity of our libc stdlib
 Chris> buffering).


	Should we then not fix our stdlib buffering then? This takes
 care of the objection that Ian had of only our code working correctly
 since ``other OSs'' already do the right thing.

	manoj
-- 
 "A stitch in time would have confused Einstein." Anonymous
Manoj Srivastava  <srivasta@acm.org> <http://www.datasync.com/%7Esrivasta/>
Key C7261095 fingerprint = CB D9 F4 12 68 07 E4 05  CC 2D 27 12 1D F5 E8 6E


Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <awkmaint@nocrew.org>:
Bug#28249; Package mawk. Full text and rfc822 format available.

Acknowledgement sent to Ian Jackson <ijackson@chiark.greenend.org.uk>:
Extra info received and forwarded to list. Copy sent to James Troup <awkmaint@nocrew.org>. Full text and rfc822 format available.

Message #30 received at 28249@bugs.debian.org (full text, mbox):

From: Ian Jackson <ijackson@chiark.greenend.org.uk>
To: Manoj Srivastava <srivasta@datasync.com>
Cc: Dale Scheetz <dwarf@polaris.net>, 28249@bugs.debian.org
Subject: Re: Bug#28249: mawk doesn't check write errors
Date: Thu, 22 Oct 1998 12:13:22 +0100 (BST)
Manoj Srivastava writes ("Re: Bug#28249: mawk doesn't check write errors"):
> Chris Fearnley <cjf@i21.com> writes:
> > The problem, as I discussed with the upstream author at the
> > time of #4293, is that mawk doesn't flush it's buffers
> > properly before closing them.  Hence unless the file is
> > greater than 4096 bytes (on Linux - other OSs seem to notice
> > the problem on close and hence do not experience this problem
> > with mawk - it's just a peculiarity of our libc stdlib
> > buffering).
> 
> 	Should we then not fix our stdlib buffering then? This takes
>  care of the objection that Ian had of only our code working correctly
>  since ``other OSs'' already do the right thing.

I don't believe that this is a Linux-specific thing.  I tested some
random program on AIX and found that it had the same problem.

The logs for #4293 don't have your conversation with the author of
mawk.

Ian.


Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <awkmaint@nocrew.org>:
Bug#28249; Package mawk. Full text and rfc822 format available.

Acknowledgement sent to Chris Fearnley <cjf@i21.com>:
Extra info received and forwarded to list. Copy sent to James Troup <awkmaint@nocrew.org>. Full text and rfc822 format available.

Message #35 received at 28249@bugs.debian.org (full text, mbox):

From: Chris Fearnley <cjf@i21.com>
To: Manoj Srivastava <srivasta@datasync.com>, 28249@bugs.debian.org, Dale Scheetz <dwarf@polaris.net>
Cc: Ian Jackson <ijackson@chiark.greenend.org.uk>
Subject: Re: Bug#28249: mawk doesn't check write errors
Date: Thu, 22 Oct 1998 17:11:11 -0400
On Wed, Oct 21, 1998 at 02:50:02PM -0500, Manoj Srivastava wrote:
> Hi,
> >>"Chris" == Chris Fearnley <cjf@i21.com> writes:
> 
>  Chris> The problem, as I discussed with the upstream author at the
>  Chris> time of #4293, is that mawk doesn't flush it's buffers
>  Chris> properly before closing them.  Hence unless the file is
>  Chris> greater than 4096 bytes (on Linux - other OSs seem to notice
>  Chris> the problem on close and hence do not experience this problem
>  Chris> with mawk - it's just a peculiarity of our libc stdlib
>  Chris> buffering).
> 
> 
> 	Should we then not fix our stdlib buffering then? This takes
>  care of the objection that Ian had of only our code working correctly
>  since ``other OSs'' already do the right thing.

No, the stdlib is within POSIX specs.  Mawk is where the bug really lives.
But most implementations handle it differently than GNU.  Which merely
explains why the upstream had trouble verifying the bug.

-- 
Christopher J. Fearnley          |  Internet21 Network Engineering
cjf@i21.com                      |  Design Science Revolutionary
http://www.i21.com/~cjf          |  Explorer in Universe
ftp://ftp.netaxs.com/people/cjf  |  "Dare to be Naïve" -- Bucky Fuller


Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <awkmaint@nocrew.org>:
Bug#28249; Package mawk. Full text and rfc822 format available.

Acknowledgement sent to Chris Fearnley <cjf@i21.com>:
Extra info received and forwarded to list. Copy sent to James Troup <awkmaint@nocrew.org>. Full text and rfc822 format available.

Message #40 received at 28249@bugs.debian.org (full text, mbox):

From: Chris Fearnley <cjf@i21.com>
To: Ian Jackson <ijackson@chiark.greenend.org.uk>, 28249@bugs.debian.org, Manoj Srivastava <srivasta@datasync.com>
Cc: Dale Scheetz <dwarf@polaris.net>
Subject: Re: Bug#28249: mawk doesn't check write errors
Date: Sun, 25 Oct 1998 01:01:03 -0400
On Thu, Oct 22, 1998 at 12:13:22PM +0100, Ian Jackson wrote:
> 
> The logs for #4293 don't have your conversation with the author of
> mawk.

Sorry, there was too much back-and-forth.  But in the end the conclusion
was fairly straightforward:  Brennan wrote me (1 Oct 1996): "The correct
fix is to add one last fflush() and error check when mawk exits.  I'll do
that and sent you the diffs."  But he never got around to it.

Instead on 19 Jan 1997 Brennan wrote: "I will fix the remaining
  problem with full writes eventually; but, the important point is
  will the user pound on a real full disk and waste 15min to 3+ hours
  of computation?  The answer is clearly, no.  What needs to happen is

    (1) the user starts with d < 4K on his disk.  Not likely on today's
        disks where 500M is small.

    (2) the mawk program then writes m bytes with d < m < 4K

    (3) The user then does not notice the full disk system message on
        the console window."

And there the matter has been sitting ever since.  Until you reminded me of
it with your recent bug report.

I guess both your report and the previous one show that users do pound
on full disks for way too long when mawk should be reporting errors to
them :(

I have asked Brennan if he has worked out a patch yet.

-- 
Christopher J. Fearnley          |  Internet21 Network Engineering
cjf@i21.com                      |  Design Science Revolutionary
http://www.i21.com/~cjf          |  Explorer in Universe
ftp://ftp.netaxs.com/people/cjf  |  "Dare to be Naïve" -- Bucky Fuller


Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <awkmaint@nocrew.org>:
Bug#28249; Package mawk. Full text and rfc822 format available.

Acknowledgement sent to Anthony Towns <aj@azure.humbug.org.au>:
Extra info received and forwarded to list. Copy sent to James Troup <awkmaint@nocrew.org>. Full text and rfc822 format available.

Message #45 received at 28249@bugs.debian.org (full text, mbox):

From: Anthony Towns <aj@azure.humbug.org.au>
To: 28249@bugs.debian.org, 28248@bugs.debian.org, 28250@bugs.debian.org, 28245@bugs.debian.org, 28251@bugs.debian.org
Subject: checking write errors
Date: Wed, 11 Nov 1998 23:29:01 +1000
[Message part 1 (text/plain, inline)]
Hello world,

Here's some sample code that demonstrates how to check this correctly
(afaict):


#include <stdio.h>
#define FOO "Foo"
int main(void) {
	if ( strlen(FOO) + 1 != printf( "%s\n", FOO ) ) {
		perror( "printf" ); /* printf reported the error */
	}

	if ( EOF == fflush(stdout) ) {
		perror( "fflush" ); /* the output was buffered, and the
		                     * error wasn't noticed until it was
				     * flushed 
				     */
	}

	exit(0);
}


[aj@sapphire ~/toys]$ ./testfull2
Foo
[aj@sapphire ~/toys]$ ./testfull2 >/dev/null
[aj@sapphire ~/toys]$ ./testfull2 >/dev/full
fflush: No space left on device


As discussed in the libc thread, fflush reports the error, not printf in
some cases.

Note, however, that if printf *does* report the error, fflush explicitly
does *not*. (change the above code to print something longer. The GPL
works for me. :)


So to report errors in every case, programs do need to explicitly check
*every* printf, *and* explicitly fflush before calling exit, and check
the return value of that.


I would, however, question the "grave" severity on these bug reports --
this bug doesn't *cause* data loss, it simply fails to report some data
loss when it happens.

HTH.

Cheers,
aj

-- 
Anthony Towns <aj@humbug.org.au> <http://azure.humbug.org.au/~aj/>
I don't speak for anyone save myself. PGP encrypted mail preferred.

``Like the ski resort of girls looking for husbands and husbands looking
  for girls, the situation is not as symmetrical as it might seem.''
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <awkmaint@nocrew.org>:
Bug#28249; Package mawk. Full text and rfc822 format available.

Acknowledgement sent to Adam Di Carlo <apharris@burrito.onshore.com>:
Extra info received and forwarded to list. Copy sent to James Troup <awkmaint@nocrew.org>. Full text and rfc822 format available.

Message #50 received at 28249@bugs.debian.org (full text, mbox):

From: Adam Di Carlo <apharris@burrito.onshore.com>
To: debian-devel@lists.debian.org
Cc: 30080@bugs.debian.org, 30369@bugs.debian.org, 28249@bugs.debian.org, 24573@bugs.debian.org, 30317@bugs.debian.org, 27381@bugs.debian.org, 30242-done@bugs.debian.org
Subject: critical bugs which can be closed or demoted
Date: 06 Dec 1998 04:05:18 -0500
[Watch the CC into the BTS, please.  Do not CC the BTS unless it's
 relevant]

30080 base: permissions for worldwriteable directories are wrong
------------------------------------------
Should be closed/demoted.  Not reproducible.


30369 Archive doesn't grok some mime types
------------------------------------------
This is basically a bug against a web page and is irrelevant to slink
release.


28249 mawk doesn't check write errors
------------------------------------------
Would require new code; not a critical bug by any real stretch of the
imagination.  Should be demoted.


24573 ethiop is in main but is not DFSG-free
------------------------------------------
I think we either need to get a actual official new license from
upstream or put it in non-free for now.


30317 fakeroot and dpkg-shlibdeps
------------------------------------------
About the fakeroot and libc6 versioned depends.  For the first part,
it wasn't really fakeroot's problem, IIRC.  Secondly, it's fixed.
Lets close this one, eh?


27381 libg++272-dev and libstdc++2.8-dev conflict, being both standard!!
------------------------------------------
Fixed in slink/potato; not something we're going to bother fixing for
hamm anyway, lets close this one and call it a day.


30242 981121 slink update: xdm locks up
------------------------------------------
I opened this bug, but I wasn't able to reproduce it.  So I'm closing
it with this message.



Ok, that's one down for sure, and 6 more than can be removed (some
with pkgs removed) from the list or should be demoted (but I'll let
the archive or pkg maintainers determine that).

It's pretty clear to me that we shouldn't ship mozilla with slink
neither, that would remove bug#26712.  We don't even have a maintainer
for it yet.

--
.....Adam Di Carlo....adam@onShore.com.....<URL:http://www.onShore.com/>


Severity set to `normal'. Request was from Brian White <bcwhite@pobox.com> to control@bugs.debian.org. Full text and rfc822 format available.

Merged 4293 28249. Request was from Torsten Landschoff <t.landschoff@gmx.net> to control@bugs.debian.org. Full text and rfc822 format available.

Reply sent to James Troup <james@nocrew.org>:
You have taken responsibility. Full text and rfc822 format available.

Notification sent to Ian Jackson <ijackson@chiark.greenend.org.uk>:
Bug acknowledged by developer. Full text and rfc822 format available.

Message #59 received at 4293-done@bugs.debian.org (full text, mbox):

From: James Troup <james@nocrew.org>
To: 4293-done@bugs.debian.org
Subject: Re: mawk doesn't report an error on full filesystems
Date: 10 Oct 1999 13:14:08 +0100
Herbert Thielen <Herbert.Thielen@lpr.e-technik.tu-muenchen.de> writes:

> Package: mawk
> Version: 1.2.2-1
> 
> Mawk doesn't report an error when writing to a full filesystem:
> 
>         $ mawk '{print}' < /etc/motd > /dev/full
>         $ echo $?
>         0
> 
> Probably no write error is catched. Gawk does it's job correct:
> 
>         $ gawk '{print}' < /etc/motd > /dev/full
>         gawk: cmd. line:1: (FILENAME=- FNR=9) warning: error writing standard output (No space left on device)

Fixed by a patch from Torsten Landschoff in mawk 1.3.3-3.

-- 
James


Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Wed Apr 16 08:10:58 2014; Machine Name: beach.debian.org

Debian Bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.