[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gzip receives read error, gives up, unlinks source file
From: |
Andrew Brown |
Subject: |
gzip receives read error, gives up, unlinks source file |
Date: |
Fri, 28 Mar 2003 13:42:12 -0500 |
User-agent: |
Mutt/1.2.5i |
my disk started throwing read errors last night, as i was trying to
compress some kernel dumps. gzip (presumably) got a read error, but
didn't notice, and completed "successfully" (ie, it wrote the summary
information to the end of the output file, unlinked the input file,
and exited with zero).
this ain't good.
you can duplicate this behavior by running gzip under gdb with a file
large enough to incur multiple reads. i used something a little over
130k.
this# dd if=/dev/zero bs=1k count=132 of=compressme
132+0 records in
132+0 records out
135168 bytes transferred in 0.009 secs (15018666 bytes/sec)
this# ls -l compressme*
-rw-r--r-- 1 root wsrc 135168 Mar 28 13:39 compressme
this# gdb obj.i386/gzip
...
(gdb) b read
Breakpoint 1 at 0x8048f38
(gdb) run compressme
Starting program: /usr/src/gnu/usr.bin/gzip/obj.i386/gzip compressme
Breakpoint 1 at 0xbdb50754
Breakpoint 1, 0xbdb50754 in read () from /usr/lib/libc.so.12
(gdb) c
Continuing.
Breakpoint 1, 0xbdb50754 in read () from /usr/lib/libc.so.12
(gdb) c
Continuing.
Breakpoint 1, 0xbdb50754 in read () from /usr/lib/libc.so.12
(gdb) ret
Make selected stack frame return now? (y or n) y
#0 0x804d082 in fill_window ()
at /usr/src/gnu/usr.bin/gzip/deflate.c:557
557 n = read_buf((char*)window+strstart+lookahead, more);
(gdb) n
Single stepping until exit from function read,
which has no line number information.
558 if (n == 0 || n == (unsigned)EOF) {
(gdb) set variable n=-1
(gdb) set variable errno=5
(gdb) d 1
(gdb) c
Continuing.
Program exited normally.
(gdb)
Suspended
this# ls compressme*
compressme.gz
this# gunzip -l compressme.gz
compressed uncompressed ratio uncompressed_name
140 98304 99.8% compressme
this# gunzip compressme.gz
this# ls -l compressme
-rw-r--r-- 1 root wsrc 98304 Mar 28 13:36 compressme
the attached patch checks that isize (the amount read in) is the same
as st_size (from the struct stat information), and makes gzip react
accordingly.
--
|-----< "CODE WARRIOR" >-----|
address@hidden * "ah! i see you have the internet
address@hidden (Andrew Brown) that goes *ping*!"
address@hidden * "information is power -- share the wealth."
gzip.patch
Description: Text document
- gzip receives read error, gives up, unlinks source file,
Andrew Brown <=