Opened 18 years ago

Closed 17 years ago

#1205 closed defect (fixed)

gdaladdo & tiffs - crash with LZW images and average resampling

Reported by: kyngchaos@… Owned by: warmerdam
Priority: normal Milestone: 1.5.0
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords: gtiff libtiff
Cc:

Description (last modified by warmerdam)

When adding overviews to an LZW compressed TIFF, and using the average resampling, I get bus errors 
at higher overview levels.  Happens with both color and grey images.  No crashes with default nearest 
resampling.  GDAL 1.3.2, libtiff 3.8.2 and latest CVS.

This is what I get in the Mac OS X crash log trace:

Command: gdaladdo
Path:    /usr/local/gislibs/bin/gdaladdo
Parent:  bash [12048]

Version: ??? (???)

PID:    24131
Thread: 0

Exception:  EXC_BAD_ACCESS (0x0001)
Codes:      KERN_PROTECTION_FAILURE (0x0002) at 0x00000810

Thread 0 Crashed:
0   <<00000000>> 	0xffff0680 __bzero + 128 (cpu_capabilities.h:184)
1   libtiff.3.dylib 	0x007867de _TIFFmemset + 31
2   libtiff.3.dylib 	0x00776b55 LZWPreDecode + 163
3   libtiff.3.dylib 	0x00784adf TIFFReadEncodedTile + 96
4   libgdal.1.dylib 	0x010711d6 GTiffRasterBand::IReadBlock(int, int, void*) + 516
5   libgdal.1.dylib 	0x01127aa9 GDALRasterBand::GetLockedBlockRef(int, int, int) + 177
6   libgdal.1.dylib 	0x0112bfc1 GDALRasterBand::IRasterIO(GDALRWFlag, int, int, int, int, void*, int, 
int, GDALDataType, int, int) + 1051
7   libgdal.1.dylib 	0x0112a015 GDALRegenerateOverviews + 1143
8   libgdal.1.dylib 	0x01129e1b GDALRegenerateOverviews + 637
9   libgdal.1.dylib 	0x01073ef6 GTiffDataset::IBuildOverviews(char const*, int, int*, int, int*, int (*)
(double, char const*, void*), void*) + 1876
10  libgdal.1.dylib 	0x0111cf7c GDALDataset::BuildOverviews(char const*, int, int*, int, int*, int (*)
(double, char const*, void*), void*) + 96
11  gdaladdo        	0x00002c7e main + 216
12  gdaladdo        	0x000024d2 _start + 228 (crt.c:272)
13  gdaladdo        	0x000023ed start + 41

Change History (5)

comment:1 by kyngchaos@…, 18 years ago

I tried another test:

1. add overviews to an uncompressed tiff - succeeds, of course.
2. copy that with tiffcp to a compressed tiff (tiffcp -c lzw in.tif out.tif).  The copy succeeds and all the 
overviews are present and now compressed.

(I tried gdal_translate, but it doesn't copy overviews, just the main image)

So, this is a workaround for now.

comment:2 by kyngchaos@…, 18 years ago

New info.  I tried libtiff from a recent CVS - Nov 8.  No crashing now, but a lot of errors.  I get about a dozen of the same error block in libtiff:

ERROR 1: colorlzw.tif:LZWDecode: Wrong length of decoded string: data probably corrupted at scanline 0
ERROR 1: TIFFReadEncodedTile() failed.
ERROR 1: IReadBlock failed at X offset 0, Y offset 1
ERROR 1: GetBlockRef failed at X block offset 0, Y block offset 1

The overviews seem to be present - tiffinfo shows them all.  But that's just the tiff directory, in QGIS all but the last overview are OK, the last one is corrupt.

So, changes in the libtiff CVS between June and now have improved it, and hopefully help in figuring out what the problem is.

comment:3 by Even Rouault, 17 years ago

#1758 is a duplicate of this one.

comment:4 by Even Rouault, 17 years ago

Milestone: 1.5.0

comment:5 by warmerdam, 17 years ago

Description: modified (diff)
Keywords: gtiff libtiff added
Priority: highnormal
Resolution: fixed
Status: newclosed

I believe this has been fixed in GDAL trunk using internal libtiff as described in #1758. Please reopen if you find otherwise.

Note: See TracTickets for help on using tickets.