Ticket #2145 (closed defect: fixed)

Opened 8 months ago

Last modified 3 months ago

[PATCH] gdaladdo segfaults with --config USE_RRD YES on GeoTIFF

Reported by: msieczka Assigned to: warmerdam
Priority: high Milestone: 1.5.2
Component: GDAL_Raster Version: svn-trunk
Severity: critical Keywords:
Cc: warmerdam

Description

This happens with any GeoTIFF. Without "--config USE_RRD YES" it works. But I badly need external overviews as the same GeoTIFF is supposed to work in QGIS, benefitting from overviews speeding up the rendering, and in ArcPad?, which happily ignores external overviews, but chokes on GeoTIFF with internal overviews.

Using GDAL 1.5 + SVN 13508 (the stable 1.5 branch), built from source on amd64 Ubuntu Dapper. This is a regression - the same used to work in GDAL 1.4.x on my machine.

Sample input attached. Backtrace:

$ gdb gdaladdo

GNU gdb 6.4-debian
Copyright 2005 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".

(gdb) run --config USE_RRD YES sample.tif 2 4
Starting program: /usr/local/bin/gdaladdo --config USE_RRD YES sample.tif 2 4
[Thread debugging using libthread_db enabled]
[New Thread 46912561229536 (LWP 12342)]
warning: Lowest section in /usr/lib/libicudata.so.34 is .hash at 00000000000000e8
0...10...20...30...40...50...60...70...80...90...100 - done.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 46912561229536 (LWP 12342)]
GDALDefaultOverviews::BuildOverviews (this=0x5171a8,
    pszBasename=<value optimized out>, pszResampling=0x400f40 "nearest",
    nOverviews=2, panOverviewList=0x7fffffe35580, nBands=1,
    panBandList=0x517b70, pfnProgress=0x400ab0 <GDALTermProgress@plt>,
    pProgressData=0x0) at gdaldefaultoverviews.cpp:520
520                 poOverDS->oOvManager.poDS = poOverDS;

(gdb) bt
#0  GDALDefaultOverviews::BuildOverviews (this=0x5171a8,
    pszBasename=<value optimized out>, pszResampling=0x400f40 "nearest",
    nOverviews=2, panOverviewList=0x7fffffe35580, nBands=1,
    panBandList=0x517b70, pfnProgress=0x400ab0 <GDALTermProgress@plt>,
    pProgressData=0x0) at gdaldefaultoverviews.cpp:520
#1  0x00002aaaaae99598 in GDALDataset::IBuildOverviews (
    this=<value optimized out>, pszResampling=0x0, nOverviews=5337512,
    panOverviewList=0x2f, nListBands=8, panBandList=<value optimized out>,
    pfnProgress=0x2, pProgressData=0x517150) at gdaldataset.cpp:1197
#2  0x00002aaaaad602d0 in GTiffDataset::IBuildOverviews (this=0x517150,
    pszResampling=0x400f40 "nearest", nOverviews=2,
    panOverviewList=0x7fffffe35580, nBands=1, panBandList=0x517b70,
    pfnProgress=0x400ab0 <GDALTermProgress@plt>, pProgressData=0x0)
    at geotiff.cpp:2163
#3  0x00002aaaaae985d8 in GDALDataset::BuildOverviews (this=0x517150,
    pszResampling=0x400f40 "nearest", nOverviews=2,
    panOverviewList=0x7fffffe35580, nListBands=1, panBandList=0x8,
    pfnProgress=0x400ab0 <GDALTermProgress@plt>, pProgressData=0x517150)
    at gdaldataset.cpp:1146
#4  0x0000000000400c52 in main (nArgc=<value optimized out>,
    papszArgv=0x516070) at gdaladdo.cpp:102

Attachments

sample.tif (24.7 kB) - added by msieczka on 01/10/08 07:16:31.
svn_gdal_trunk_gdaldefaultoverviews_fix_2145.patch (0.6 kB) - added by rouault on 01/28/08 16:39:06.

Change History

01/10/08 07:16:31 changed by msieczka

  • attachment sample.tif added.

01/10/08 12:42:14 changed by rouault

Apparently, this is due to r12795 : "lots of magic related to building mask overviews with normal overviews". So I let it to FrankW. (There are clearly missing tests of pointers against NULL pointer).

In the meantime, if you want to create external overview, you might try this as a workaround: "chmod a-w sample.tif" and gdaladdo on it afterwards.

01/10/08 12:55:39 changed by warmerdam

  • priority changed from normal to high.
  • status changed from new to assigned.
  • component changed from Utilities to GDAL_Raster.

01/28/08 16:38:34 changed by rouault

I would suggest the attached patch, at least it prevents the application from crashing, not sure it's really correct however. I didn't like it very much, as it looks more like a workaround than a real fix, but I saw that there was exactly the same code in GDALDefaultOverviews::Initialize... I'm a bit surprised that poBand->GetDataset? may return NULL however.

01/28/08 16:39:06 changed by rouault

  • attachment svn_gdal_trunk_gdaldefaultoverviews_fix_2145.patch added.

02/03/08 14:07:48 changed by rouault

  • summary changed from gdaladdo segfaults with --config USE_RRD YES on GeoTIFF to [PATCH] gdaladdo segfaults with --config USE_RRD YES on GeoTIFF.

05/21/08 13:07:16 changed by rouault

  • status changed from assigned to closed.
  • cc set to warmerdam.
  • resolution set to fixed.

Well, finally my patch is probably not that bad since the test is in fact the same as the one done at line 169.

Commited in trunk in r14498 and in branches/1.5 in r14499

05/21/08 13:17:16 changed by rouault

tiff_ovr_6 added in r14500