2011.06.15 09:25 "Re: [Tiff] bug in G4 encoder.", by Erik Thiele

2011.06.15 15:00 "Re: [Tiff] bug in G4 encoder.", by Steve Underwood

On 06/14/2011 09:46 PM, Erik Thiele wrote:

Am 14.06.2011 15:11, schrieb Steve Underwood:

On 06/14/2011 07:06 PM, Erik Thiele wrote:

there is a bug in the G4 encoder. attached to this email you find a file "gimpcrop.g3.tiff". it is a correct TIFF file encoded with G3. you can open it with the usual viewers.

now do this:

tiffcp -c g4 gimpcrop.g3.tiff out.tiff

the file gets converted from G3 to G4. the following command shows that the output file is corrupted.

tiffcp out.tiff lala.tiff

Fax4Decode: out.tiff: Bad code word at line 17 of strip 9 (x 0).

Fax4Decode: Warning, out.tiff: Premature EOL at line 17 of strip 9 (got 0, expected 4519).

Fax4Decode: Warning, out.tiff: Line length mismatch at line 44 of strip 9 (got 4520, expected 4519).

Fax4Decode: Warning, out.tiff: Line length mismatch at line 53 of strip 9 (got 4574, expected 4519).

Fax4Decode: Warning, out.tiff: Premature EOL at line 63 of strip 9 (got 72, expected 4519).

bughunt$

you can open lala.tiff in a viewer and get error messages. usually the viewer anyway views the image, but it contains a horizontal black line, which should not be there. in addition it contains more pixel errors.

in case you cannot reproduce the problem, i attached lala.tiff to this email.

tiffcp sais:
LIBTIFF, Version 3.9.4
my debian version of the libtiff4 package is 3.9.4-5+squeeze2

I have recently reported this bug on the debian bug tracking system and am hereby forwarding it to you.

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=630042

cu& thanks

Its a rather odd looking image, but libtiff 3.9.5 converts the odd looking G3 image into a matching G4 image.

i downloaded 3.9.4 (as this is the supposed buggy version that my debian uses) and 3.9.5 (as you suggest it is not buggy). i unpacked both and then did:

cd tiff-3.9.5
./configure --prefix=/home/global/erik/localinst/tiff-3.9.5
make install

cd tiff-3.9.4
./configure --prefix=/home/global/erik/localinst/tiff-3.9.4
make install

then i first checked that there is no linker problems by calling ldd:

bughunt$ ldd ~/localinst/tiff-3.9.4/bin/tiffcp
        linux-gate.so.1 => (0xb7723000)
        libtiff.so.3 => /home/global/erik/localinst/tiff-3.9.4/lib/libtiff.so.3
(0xb76c6000)
        libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0xb768f000)
        libz.so.1 => /usr/lib/libz.so.1 (0xb767a000)
        libm.so.6 => /lib/i686/cmov/libm.so.6 (0xb7654000)
        libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb750e000)
        /lib/ld-linux.so.2 (0xb7724000)

bughunt$ ldd ~/localinst/tiff-3.9.5/bin/tiffcp
        linux-gate.so.1 => (0xb778e000)
        libtiff.so.3 => /home/global/erik/localinst/tiff-3.9.5/lib/libtiff.so.3
(0xb7732000)
        libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0xb76fb000)
        libz.so.1 => /usr/lib/libz.so.1 (0xb76e6000)
        libm.so.6 => /lib/i686/cmov/libm.so.6 (0xb76c0000)
        libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb757a000)
        /lib/ld-linux.so.2 (0xb778f000)

now i called tiffcp to produce output pictures:

bughunt$ ~/localinst/tiff-3.9.4/bin/tiffcp -c g4 gimpcrop.g3.tiff lala.3.9.4.tiff

bughunt$ ~/localinst/tiff-3.9.5/bin/tiffcp -c g4 gimpcrop.g3.tiff lala.3.9.5.tiff

i compared output pictures to see they are same:

bughunt$ md5sum lala.3.9.4.tiff lala.3.9.5.tiff
e9e0c41b94a32bfd620be39c3c2894c7 lala.3.9.4.tiff
e9e0c41b94a32bfd620be39c3c2894c7 lala.3.9.5.tiff

i verified that the outputs are buggy:

bughunt$ display lala.3.9.5.tiff display: lala.3.9.5.tiff: Bad code word at line 17 of strip 9 (x 0). `Fax4Decode' @ warning/tiff.c/TIFFErrors/493. display: lala.3.9.5.tiff: Premature EOL at line 17 of strip 9 (got 0, expected 4519). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/703. display: lala.3.9.5.tiff: Line length mismatch at line 44 of strip 9 (got 4520, expected 4519). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/703. display: lala.3.9.5.tiff: Line length mismatch at line 53 of strip 9 (got 4574, expected 4519). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/703. display: lala.3.9.5.tiff: Premature EOL at line 63 of strip 9 (got 72, expected 4519). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/703.

the pictures look as corrupted as described in first email.

what kind of additional problem do we have here?

bughunt$ gcc --version
gcc (Debian 4.4.5-8) 4.4.5

how can we debug?

I actually used the libtiff 3.9.5 in Fedora 14 when I got good results. Perhaps it has been patched in some way. There was breakage of the G4 codec a while ago, when a fix to stop a potential buffer overflow screwed up some images. Is this the same issue resurfacing?

Steve