Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#2145 closed defect (fixed)

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

Reported by: msieczka Owned by: 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 (2)

sample.tif (24.7 KB) - added by msieczka 11 years ago.
svn_gdal_trunk_gdaldefaultoverviews_fix_2145.patch (633 bytes) - added by Even Rouault 11 years ago.

Download all attachments as: .zip

Change History (8)

Changed 11 years ago by msieczka

Attachment: sample.tif added

comment:1 Changed 11 years ago by Even 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.

comment:2 Changed 11 years ago by warmerdam

Component: UtilitiesGDAL_Raster
Priority: normalhigh
Status: newassigned

comment:3 Changed 11 years ago by Even 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.

Changed 11 years ago by Even Rouault

comment:4 Changed 11 years ago by Even Rouault

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

comment:5 Changed 11 years ago by Even Rouault

Cc: warmerdam added
Resolution: fixed
Status: assignedclosed

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

comment:6 Changed 11 years ago by Even Rouault

tiff_ovr_6 added in r14500

Note: See TracTickets for help on using tickets.