bug-gawk
[Top][All Lists]
Advanced

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

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


From: Assaf Gordon
Subject: [bug-gawk] Possible regression in gawk 4.x regarding I/O errors
Date: Mon, 21 Jul 2014 16:31:43 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

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

Attachment: create_corrupted_filesystem.sh
Description: application/shellscript


reply via email to

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