bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] Possible regression in gawk 4.x regarding I/O errors


From: Aharon Robbins
Subject: Re: [bug-gawk] Possible regression in gawk 4.x regarding I/O errors
Date: Thu, 24 Jul 2014 03:14:35 -0400
User-agent: Heirloom mailx 12.5 6/20/10

Hi Assaf.

Re this:

> Date: Mon, 21 Jul 2014 16:31:43 -0400
> From: Assaf Gordon <address@hidden>
> To: address@hidden
> Subject: [bug-gawk] Possible regression in gawk 4.x regarding I/O errors
>
> Hello,
>
> I've encountered a situation where I think gawk 4.x fails to detect
> reads errors in input file (gawk 3.1.8 properly detects it).
> 
> To reproduce, I've made a script which creates a corrupted file-systems
> that reproduces the error (attached).
>
> The script creates "bad_disk.img" - an ext3 file-system with two corrupted
> text files (the script does not require root, but requires 'mkfs.ext3'
> and 'debugfs' to be installed).
>
> To mount it, run:
>      ./create_corrupted_filesystem.sh
>      mkdir baddisk
>      sudo mount bad_disk.img ./baddisk
>
> Then, "cat" will verify both have input errors:
>      $ cat ./baddisk/numbers.txt > /dev/null && echo ok
>      cat: ./baddisk/numbers.txt: Input/output error
>      $ cat ./baddisk/bottles.txt > /dev/null && echo ok
>      cat: ./baddisk/bottles.txt: Input/output error
>
> But AWK will fail to detect the error in the second file:
>      $ awk '{print}' ./baddisk/numbers.txt > /dev/null && echo ok
>      awk: cmd. line:1: (FILENAME=./baddisk/numbers.txt FNR=2679) fatal: error 
> reading input file `./baddisk/numbers.txt': Input/output error
>      $ awk '{print}' ./baddisk/bottles.txt > /dev/null && echo ok
>      ok
>
> There is something about the content of the "bottles.txt" file that makes
> AWK not detect the error - perhaps because it contains numbers and text?
>
>      $ head -n5 ./baddisk/*.txt
>      ==> ./baddisk/bottles.txt <==
>      2000 bottles of beer on the wall
>      1999 bottles of beer on the wall
>      1998 bottles of beer on the wall
>      1997 bottles of beer on the wall
>      1996 bottles of beer on the wall
>
>      ==> ./baddisk/numbers.txt <==
>      1
>      2
>      3
>      4
>      5
>
>
> This is reproducible with gawk-4.0.1, gawk-4.0.2, gawk-4.1.1, and latest git.
> gawk-3.1.8 properly detects the errors in both files.
> Tested on Ubuntu 14.04 amd64 and Debian 7 i686.
>
> Regards,
>   - Assaf

Interesting test case. I was able to reproduce it. An enormous THANK YOU
for the excellent bug report.

Here is a patch that doesn't break 'make test'.  Let me know if it works
for you.

Thanks,

Arnold
------------------
diff --git a/io.c b/io.c
index 57d4af2..c291dc9 100644
--- a/io.c
+++ b/io.c
@@ -596,6 +596,8 @@ inrec(IOBUF *iop, int *errcode)
                INCREMENT_REC(NR);
                INCREMENT_REC(FNR);
                set_record(begin, cnt);
+               if (*errcode > 0)
+                       retval = 1;
        }
 
        return retval;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]