[Gdal-dev] gdalwarp -tps weirdness

Hamish hamish_nospam at yahoo.com
Mon Jun 6 05:08:56 EDT 2005


> I'm trying to use gdalwarp's new thin plate spline warping but it is
> doing funny things. Seems like a memory stomping problem but I'm not
> sure. Doing things like changing the order of GCPs (dozen placed by
> hand with gdal_translate) or the length of the output filename makes
> it either work or have the output go haywire.
> 
> anybody come across this before?
> 
> 
> GDAL 1.2.6.0 on Debian.
> 
> entered in GDAL bugzilla bug # 864
>   http://bugzilla.remotesensing.org/show_bug.cgi?id=864



[cc GDAL Bug 864]


recompiled on another machine from source (previous was with the Debian
packages). Same result but now I can use gdb for two segfaults I can
trigger, in addition to the weird output bug mentioned above.

Both segfaults trace back to the GDALWarpOperation::WarpRegion stage.



Segfault 1) Different GeoTIFF image than the above failure, it gets to 
100% complete, then segfaults. Leaves behind a corrupted output GeoTiff.


Here's the gdb session:


$ gdb `which gdalwarp`
(gdb) run -tps -co compress=lzw 8right_gcp.tif 8right_warped_xyz123def.tif
Starting program: /usr/local/bin/gdalwarp -tps -co compress=lzw 8right_gcp.tif 8right_warped_xyz123def.tif
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 9987)]
Creating output file that is 9627P x 6717L.
:0...10...20...30...40...50...60...70...80...90...100 - done.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 9987)]
0x4070756b in memset () from /lib/libc.so.6
(gdb) bt f
#0  0x4070756b in memset () from /lib/libc.so.6
No symbol table info available.
#1  0x405138ad in _TIFFmemset () from /usr/lib/libtiff.so.4
No symbol table info available.
#2  0x40508833 in TIFFInitSGILog () from /usr/lib/libtiff.so.4
No symbol table info available.
#3  0x40511f85 in TIFFReadBufferSetup () from /usr/lib/libtiff.so.4
No symbol table info available.
#4  0x4051131c in TIFFReadEncodedStrip () from /usr/lib/libtiff.so.4
No symbol table info available.
#5  0x400f5e05 in GTiffRasterBand::IReadBlock (this=0x80512e8, nBlockXOff=0, nBlockYOff=0, 
    pImage=0x8a9ab00) at geotiff.cpp:518
        poGDS = (GTiffDataset *) 0x80511d8
        nBlockBufSize = 9627
        nBlockId = 0
        nBlockIdBand0 = 0
        eErr = CE_None
#6  0x401a8d3a in GDALRasterBand::GetBlockRef (this=0x80512e8, nXBlockOff=0, nYBlockOff=0, 
    bJustInitialize=0) at gdalrasterband.cpp:1142
        poBlock = (class GDALRasterBlock *) 0x8706db0
#7  0x401ac1da in GDALRasterBand::IRasterIO (this=0x80512e8, eRWFlag=GF_Write, nXOff=4813, nYOff=0, 
    nXSize=4814, nYSize=6717, pData=0x41409008, nBufXSize=4814, nBufYSize=6717, eBufType=GDT_Byte, 
    nPixelSpace=1, nLineSpace=4814) at rasterio.cpp:175
        bJustInitialize = 0
        nSrcByteOffset = 0
        nBandDataSize = 1
        nBufDataSize = 1
        pabySrcBlock = (GByte *) 0x0
        poBlock = (class GDALRasterBlock *) 0x40701176
        nLBlockX = -1
        nLBlockY = 0
        iBufYOff = 0
        iBufXOff = 1081866368
        iSrcY = 0
        iSrcX = 0
        dfSrcX = 2.1219957909652723e-314
        dfSrcY = 7.7813168390427143e-292
        dfSrcXInc = 48.371032714843786
        dfSrcYInc = 263.61883544908824
#8  0x401a00b0 in GDALDataset::IRasterIO (this=0x80511d8, eRWFlag=GF_Write, nXOff=4813, nYOff=0, 
    nXSize=4814, nYSize=6717, pData=0x41409008, nBufXSize=4814, nBufYSize=6717, eBufType=GDT_Byte, 
    nBandCount=1, panBandMap=0x80508c0, nPixelSpace=1, nLineSpace=4814, nBandSpace=32335638)
    at gdaldataset.cpp:1290
        poBand = (class GDALRasterBand *) 0x80512e8
        pabyBandData = (GByte *) 0x41409008 ""
        iBandIndex = 0
        eErr = CE_None
#9  0x401a048c in GDALDataset::RasterIO (this=0x80511d8, eRWFlag=GF_Write, nXOff=4813, nYOff=0, 
    nXSize=4814, nYSize=6717, pData=0x41409008, nBufXSize=4814, nBufYSize=6717, eBufType=GDT_Byte, 
    nBandCount=1, panBandMap=0x80508c0, nPixelSpace=1, nLineSpace=4814, nBandSpace=32335638)
    at gdaldataset.cpp:1481
        i = 1
        bNeedToFreeBandMap = 0
        eErr = CE_None
#10 0x401a0531 in GDALDatasetRasterIO (hDS=0x80511d8, eRWFlag=GF_Write, nXOff=4813, nYOff=0, 
    nXSize=4814, nYSize=6717, pData=0x41409008, nBufXSize=4814, nBufYSize=6717, eBufType=GDT_Byte, 
    nBandCount=1, panBandMap=0x80508c0, nPixelSpace=0, nLineSpace=0, nBandSpace=0)
    at gdaldataset.cpp:1515
        poDS = (GDALDataset *) 0x80511d8
#11 0x401cf63e in GDALWarpOperation::WarpRegion (this=0xbffff9b0, nDstXOff=4813, nDstYOff=0, 
    nDstXSize=4814, nDstYSize=6717, nSrcXOff=0, nSrcYOff=0, nSrcXSize=1200, nSrcYSize=11100)
    at gdalwarpoperation.cpp:1190
        eErr = CE_None
        iBand = 1
        pDstBuffer = (void *) 0x41409008
        nWordSize = 1
        nBandSize = 32335638
        pszInitDest = 0x8055d8a "0"
#12 0x401ce7d9 in GDALWarpOperation::ChunkAndWarpImage (this=0xbffff9b0, nDstXOff=0, nDstYOff=0, 
    nDstXSize=9627, nDstYSize=6717) at gdalwarpoperation.cpp:683
        panThisChunk = (int *) 0x80570d8
        dfChunkPixels = 32335638
        eErr = CE_None
        iChunk = 1
        dfPixelsProcessed = 32328921
        dfTotalPixels = 64664559
#13 0x0804aca6 in main (argc=6, argv=0x80504a8) at gdalwarp.cpp:657
        hSrcDS = 0x80509f8
        hDstDS = 0x80511d8
        pszFormat = 0x804b6cc "GTiff"
        pszTargetSRS = 0x0
        pszSourceSRS = 0x0
        pszSrcFilename = 0x804fdc0 "8right_gcp.tif"
        pszDstFilename = 0x80504c8 "8right_warped_xyz123def.tif"
        bCreateOutput = 1
        i = 1
        nOrder = -1
        hTransformArg = (void *) 0x8057358
        hGenImgProjArg = (void *) 0x8055f60
        hApproxArg = (void *) 0x8057358
        papszWarpOptions = (char **) 0x8055d60
        dfErrorThreshold = 0.125
        dfWarpMemoryLimit = 0
        pfnTransformer = 0x8049454 <GDALApproxTransform>
        papszCreateOptions = (char **) 0x0
        eOutputType = GDT_Unknown
        eWorkingType = GDT_Unknown
        eResampleAlg = GRA_NearestNeighbour
        pszSrcNodata = 0x0
        pszDstNodata = 0x0
        bMulti = 0
        psWO = (GDALWarpOptions *) 0x80574d0
        oWO = {_vptr.GDALWarpOperation = 0x403735d0, psOptions = 0x8056b60, 
  dfProgressBase = 0.49994806274020981, dfProgressScale = 0.50005193725979014, hThread1Mutex = 0x0, 
  hThread2Mutex = 0x0, hIOMutex = 0x0, hWarpMutex = 0x0, nChunkListCount = 2, nChunkListMax = 3, 
  panChunkList = 0x80570b8, bReportTimings = 0, nLastTimeReported = 0}
(gdb) l
657                 oWO.ChunkAndWarpImage( 0, 0, 
658                                        GDALGetRasterXSize( hDstDS ),
659                                        GDALGetRasterYSize( hDstDS ) );
660         }
661     
662     /* -------------------------------------------------------------------- */
663     /*      Cleanup                                                         */
664     /* -------------------------------------------------------------------- */
665         if( hApproxArg != NULL )
666             GDALDestroyApproxTransformer( hApproxArg );
(gdb) frame 5
#5  0x400f5e05 in GTiffRasterBand::IReadBlock (this=0x80512e8, nBlockXOff=0, nBlockYOff=0, 
    pImage=0x8a9ab00) at geotiff.cpp:518
518                 if( TIFFReadEncodedStrip( poGDS->hTIFF, nBlockId, pImage,
(gdb) l
513                     eErr = CE_Failure;
514                 }
515             }
516             else
517             {
518                 if( TIFFReadEncodedStrip( poGDS->hTIFF, nBlockId, pImage,
519                                           nBlockBufSize ) == -1 )
520                 {
521                     memset( pImage, 0, nBlockBufSize );
522                     CPLError( CE_Failure, CPLE_AppDefined,
(gdb) frame 6
#6  0x401a8d3a in GDALRasterBand::GetBlockRef (this=0x80512e8, nXBlockOff=0, nYBlockOff=0, 
    bJustInitialize=0) at gdalrasterband.cpp:1142
1142            if( !bJustInitialize
(gdb) l
1137                CPLError( CE_Failure, CPLE_AppDefined, "Internalize failed",
1138                          nXBlockOff, nYBlockOff);
1139                return( NULL );
1140            }
1141    
1142            if( !bJustInitialize
1143             && IReadBlock(nXBlockOff,nYBlockOff,poBlock->GetDataRef()) != CE_None)
1144            {
1145                delete poBlock;
1146                CPLError( CE_Failure, CPLE_AppDefined,



$ gdalinfo 8right_gcp.tif
Driver: GTiff/GeoTIFF
Size is 1200, 11100
Coordinate System is `'
GCP Projection = 
GCP[  0]: Id=1, Info=
          (1198,3) -> [...]
[...]
GCP[ 23]: Id=24, Info=
          (970,11040) -> [...]
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,11100.0)
Upper Right ( 1200.0,    0.0)
Lower Right ( 1200.0,11100.0)
Center      (  600.0, 5550.0)
Band 1 Block=1200x6 Type=Byte, ColorInterp=Gray






--------

Segfault 2) Another segfault in another way using a different file.
I guess this one's only a symptom of the matrix gen failing:



$ gdb `which gdalwarp`
[...]
(gdb) run -tps -co compress=lzw 18left_gcp.tif 18left_warped_abcdefg.tif
Starting program: /usr/local/bin/gdalwarp -tps -co compress=lzw 18left_gcp.tif 18left_warped_abcdefg.tif
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 9969)]
 There is a problem to invert the interpolation matrix
Creating output file that is 4513P x 12251L.
 There is a problem to invert the interpolation matrix
:0.
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 9969)]
0x401ca487 in GWKNearestNoMasksByte (poWK=0xbffff7d0) at gdalwarpkernel.cpp:2065
2065                    poWK->papabyDstImage[iBand][iDstOffset] = 
(gdb) bt f
#0  0x401ca487 in GWKNearestNoMasksByte (poWK=0xbffff7d0) at gdalwarpkernel.cpp:2065
        iSrcX = -2147483648
        iSrcOffset = -2147483648
        iSrcY = -2147483648
        iBand = 0
        iDstOffset = 0
        iDstX = 0
        iDstY = 0
        nDstXSize = 4513
        nDstYSize = 12251
        nSrcXSize = 0
        nSrcYSize = 0
        eErr = CE_None
        padfX = (double *) 0x80594f8
        padfY = (double *) 0x8062208
        padfZ = (double *) 0x806af18
        pabSuccess = (int *) 0x8073c28
#1  0x401c695e in GDALWarpKernel::PerformWarp (this=0xbffff7d0) at gdalwarpkernel.cpp:591
        eErr = CE_None
#2  0x401cfda6 in GDALWarpOperation::WarpRegionToBuffer (this=0xbffff9b0, nDstXOff=0, nDstYOff=0, 
    nDstXSize=4513, nDstYSize=12251, pDataBuf=0x40f04008, eBufDataType=GDT_Byte, nSrcXOff=0, 
    nSrcYOff=0, nSrcXSize=0, nSrcYSize=0) at gdalwarpoperation.cpp:1475
        eErr = CE_None
        i = 1
        nWordSize = 1
        oWK = {_vptr.GDALWarpKernel = 0x40373570, papszWarpOptions = 0x8056b80, 
  eResample = GRA_NearestNeighbour, eWorkingDataType = GDT_Byte, nBands = 1, nSrcXSize = 0, 
  nSrcYSize = 0, papabySrcImage = 0x8056200, papanBandSrcValid = 0x0, panUnifiedSrcValid = 0x0, 
  pafUnifiedSrcDensity = 0x0, nDstXSize = 4513, nDstYSize = 12251, papabyDstImage = 0x8056f40, 
  panDstValid = 0x0, pafDstDensity = 0x0, nSrcXOff = 0, nSrcYOff = 0, nDstXOff = 0, nDstYOff = 0, 
  pfnTransformer = 0x8049454 <GDALApproxTransform>, pTransformerArg = 0x8056ef0, 
  pfnProgress = 0x8049834 <GDALTermProgress>, pProgress = 0x0, dfProgressBase = 0, 
  dfProgressScale = 1}
#3  0x401cf5a8 in GDALWarpOperation::WarpRegion (this=0xbffff9b0, nDstXOff=0, nDstYOff=0, 
    nDstXSize=4513, nDstYSize=12251, nSrcXOff=0, nSrcYOff=0, nSrcXSize=0, nSrcYSize=0)
    at gdalwarpoperation.cpp:1181
        eErr = CE_None
        iBand = 1
        pDstBuffer = (void *) 0x40f04008
        nWordSize = 1
        nBandSize = 55288763
        pszInitDest = 0x8056b9a "0"
#4  0x401ce7d9 in GDALWarpOperation::ChunkAndWarpImage (this=0xbffff9b0, nDstXOff=0, nDstYOff=0, 
    nDstXSize=4513, nDstYSize=12251) at gdalwarpoperation.cpp:683
        panThisChunk = (int *) 0x8056f18
        dfChunkPixels = 55288763
        eErr = 134532600
        iChunk = 0
        dfPixelsProcessed = 0
        dfTotalPixels = 55288763
#5  0x0804aca6 in main (argc=6, argv=0x80504a8) at gdalwarp.cpp:657
        hSrcDS = 0x80509f8
        hDstDS = 0x8056230
        pszFormat = 0x804b6cc "GTiff"
        pszTargetSRS = 0x0
        pszSourceSRS = 0x0
        pszSrcFilename = 0x804fdc0 "18left_gcp.tif"
        pszDstFilename = 0x80504c8 "18left_warped_abcdefg.tif"
        bCreateOutput = 1
        i = 1
        nOrder = -1
        hTransformArg = (void *) 0x8056ef0
        hGenImgProjArg = (void *) 0x80511d8
        hApproxArg = (void *) 0x8056ef0
        papszWarpOptions = (char **) 0x8050750
        dfErrorThreshold = 0.125
        dfWarpMemoryLimit = 0
        pfnTransformer = 0x8049454 <GDALApproxTransform>
        papszCreateOptions = (char **) 0x0
        eOutputType = GDT_Unknown
        eWorkingType = GDT_Unknown
        eResampleAlg = GRA_NearestNeighbour
        pszSrcNodata = 0x0
        pszDstNodata = 0x0
        bMulti = 0
        psWO = (GDALWarpOptions *) 0x8057268
        oWO = {_vptr.GDALWarpOperation = 0x403735d0, psOptions = 0x8056af0, dfProgressBase = 0, 
  dfProgressScale = 1, hThread1Mutex = 0x0, hThread2Mutex = 0x0, hIOMutex = 0x0, hWarpMutex = 0x0, 
  nChunkListCount = 1, nChunkListMax = 1, panChunkList = 0x8056f18, bReportTimings = 0, 
  nLastTimeReported = 0}
(gdb) l
657                 oWO.ChunkAndWarpImage( 0, 0, 
658                                        GDALGetRasterXSize( hDstDS ),
659                                        GDALGetRasterYSize( hDstDS ) );
660         }
661     
662     /* -------------------------------------------------------------------- */
663     /*      Cleanup                                                         */
664     /* -------------------------------------------------------------------- */
665         if( hApproxArg != NULL )
666             GDALDestroyApproxTransformer( hApproxArg );
(gdb) frame 0
#0  0x401ca487 in GWKNearestNoMasksByte (poWK=0xbffff7d0) at gdalwarpkernel.cpp:2065
2065                    poWK->papabyDstImage[iBand][iDstOffset] = 
(gdb) l
2060    
2061                iDstOffset = iDstX + iDstY * nDstXSize;
2062    
2063                for( iBand = 0; iBand < poWK->nBands; iBand++ )
2064                {
2065                    poWK->papabyDstImage[iBand][iDstOffset] = 
2066                        poWK->papabySrcImage[iBand][iSrcOffset];
2067                }
2068            }
2069    
(gdb) frame 1
#1  0x401c695e in GDALWarpKernel::PerformWarp (this=0xbffff7d0) at gdalwarpkernel.cpp:591
591             return GWKNearestNoMasksByte( this );
(gdb) l
586             && papanBandSrcValid == NULL
587             && panUnifiedSrcValid == NULL
588             && pafUnifiedSrcDensity == NULL
589             && panDstValid == NULL
590             && pafDstDensity == NULL )
591             return GWKNearestNoMasksByte( this );
592     
593         if( eWorkingDataType == GDT_Byte
594             && eResample == GRA_Bilinear
595             && papanBandSrcValid == NULL



So I guess this segfault happens as iSrcOffset being used uninitialized
in gdalwarpkernel.cpp line 2066 ......





thanks,
Hamish



More information about the Gdal-dev mailing list