Opened 9 years ago

Closed 5 years ago

#6068 closed defect (wontfix)

'vector subscript out of range' when read block from PCIDSK file

Reported by: bcolombe Owned by: warmerdam
Priority: normal Milestone: closed_because_of_github_migration
Component: default Version: 1.11.1
Severity: normal Keywords:
Cc:

Description

Provided file is a tiled .pix created in PCI Geomatica 2015 SP1. Image has dimensions X: 6193 and Y: 6741 with block size of 512 x 512.

When attempt GDALRasterBand::ReadBlock or GDALRasterBand::GetLockedBlockRef at xblock:0, yblock:13, get 'vector subscript out of range' in SysVirtualFile::GetBlockSegment. This happens with multiple files of the same format, always when reading the first block of the last row.

If instead use RasterIO to read on block boundaries, then works.

Change History (4)

comment:2 by Even Rouault, 9 years ago

I can indeed reproduce an issue, although I didn't got a crash, but I believe this could have happened as well.

$ valgrind gdal_translate DEM_016870_hilly_10m_new.pix -srcwin 0 6700 512 41 out.tif
==22605== Memcheck, a memory error detector
==22605== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==22605== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==22605== Command: gdal_translate DEM_016870_hilly_10m_new.pix -srcwin 0 6700 512 41 out.tif
==22605== 
Input file size is 6193, 6741
Warning 1: Unable to export GeoTIFF file with different datatypes per
different bands. All bands should have the same types in TIFF.
0==22605== Conditional jump or move depends on uninitialised value(s)
==22605==    at 0x562CF83: PCIDSK::SysVirtualFile::LoadBlocks(int, int, void*) (sysvirtualfile.cpp:504)
==22605==    by 0x562C558: PCIDSK::SysVirtualFile::ReadFromFile(void*, unsigned long long, unsigned long long) (sysvirtualfile.cpp:299)
==22605==    by 0x528A43F: PCIDSK::CTiledChannel::ReadBlock(int, void*, int, int, int, int) (ctiledchannel.cpp:388)
==22605==    by 0x5563086: PCIDSK2Band::IReadBlock(int, int, void*) (pcidskdataset2.cpp:525)
==22605==    by 0x5736380: GDALRasterBand::GetLockedBlockRef(int, int, int) (gdalrasterband.cpp:1124)
==22605==    by 0x574EAED: GDALRasterBand::IRasterIO(GDALRWFlag, int, int, int, int, void*, int, int, GDALDataType, long long, long long, GDALRasterIOExtraArg*) (rasterio.cpp:324)
==22605==    by 0x56EF1A3: GDALDataset::BandBasedRasterIO(GDALRWFlag, int, int, int, int, void*, int, int, GDALDataType, int, int*, long long, long long, long long, GDALRasterIOExtraArg*) (gdaldataset.cpp:1637)
==22605==    by 0x56EF029: GDALDataset::IRasterIO(GDALRWFlag, int, int, int, int, void*, int, int, GDALDataType, int, int*, long long, long long, long long, GDALRasterIOExtraArg*) (gdaldataset.cpp:1581)
==22605==    by 0x56EF923: GDALDataset::RasterIO(GDALRWFlag, int, int, int, int, void*, int, int, GDALDataType, int, int*, long long, long long, long long, GDALRasterIOExtraArg*) (gdaldataset.cpp:1928)
==22605==    by 0x56A11EE: VRTSimpleSource::DatasetRasterIO(int, int, int, int, void*, int, int, GDALDataType, int, int*, long long, long long, long long, GDALRasterIOExtraArg*) (vrtsources.cpp:1327)
==22605==    by 0x56896F1: VRTDataset::IRasterIO(GDALRWFlag, int, int, int, int, void*, int, int, GDALDataType, int, int*, long long, long long, long long, GDALRasterIOExtraArg*) (vrtdataset.cpp:1457)
==22605==    by 0x56EF923: GDALDataset::RasterIO(GDALRWFlag, int, int, int, int, void*, int, int, GDALDataType, int, int*, long long, long long, long long, GDALRasterIOExtraArg*) (gdaldataset.cpp:1928)
==22605== 
==22605== Conditional jump or move depends on uninitialised value(s)
==22605==    at 0x562CFFA: PCIDSK::SysVirtualFile::LoadBlocks(int, int, void*) (sysvirtualfile.cpp:517)
==22605==    by 0x562C558: PCIDSK::SysVirtualFile::ReadFromFile(void*, unsigned long long, unsigned long long) (sysvirtualfile.cpp:299)
==22605==    by 0x528A43F: PCIDSK::CTiledChannel::ReadBlock(int, void*, int, int, int, int) (ctiledchannel.cpp:388)
==22605==    by 0x5563086: PCIDSK2Band::IReadBlock(int, int, void*) (pcidskdataset2.cpp:525)
==22605==    by 0x5736380: GDALRasterBand::GetLockedBlockRef(int, int, int) (gdalrasterband.cpp:1124)
==22605==    by 0x574EAED: GDALRasterBand::IRasterIO(GDALRWFlag, int, int, int, int, void*, int, int, GDALDataType, long long, long long, GDALRasterIOExtraArg*) (rasterio.cpp:324)
==22605==    by 0x56EF1A3: GDALDataset::BandBasedRasterIO(GDALRWFlag, int, int, int, int, void*, int, int, GDALDataType, int, int*, long long, long long, long long, GDALRasterIOExtraArg*) (gdaldataset.cpp:1637)
==22605==    by 0x56EF029: GDALDataset::IRasterIO(GDALRWFlag, int, int, int, int, void*, int, int, GDALDataType, int, int*, long long, long long, long long, GDALRasterIOExtraArg*) (gdaldataset.cpp:1581)
==22605==    by 0x56EF923: GDALDataset::RasterIO(GDALRWFlag, int, int, int, int, void*, int, int, GDALDataType, int, int*, long long, long long, long long, GDALRasterIOExtraArg*) (gdaldataset.cpp:1928)
==22605==    by 0x56A11EE: VRTSimpleSource::DatasetRasterIO(int, int, int, int, void*, int, int, GDALDataType, int, int*, long long, long long, long long, GDALRasterIOExtraArg*) (vrtsources.cpp:1327)
==22605==    by 0x56896F1: VRTDataset::IRasterIO(GDALRWFlag, int, int, int, int, void*, int, int, GDALDataType, int, int*, long long, long long, long long, GDALRasterIOExtraArg*) (vrtdataset.cpp:1457)
==22605==    by 0x56EF923: GDALDataset::RasterIO(GDALRWFlag, int, int, int, int, void*, int, int, GDALDataType, int, int*, long long, long long, long long, GDALRasterIOExtraArg*) (gdaldataset.cpp:1928)
==22605== 

Couldn't find a fix though with my current understanding of that part of the code base. It indeed looks related to the handling of partial tiles at the bottom of the raster.

comment:3 by Even Rouault, 9 years ago

And I got the following assert to trigger:

--- frmts/pcidsk/sdk/core/sysvirtualfile.cpp	2015-08-11 18:41:15.143315216 +0200
+++ frmts/pcidsk/sdk/core/sysvirtualfile.cpp.dbg	2015-08-11 18:41:12.023100626 +0200
@@ -118,6 +118,7 @@
     if( requested_block >= blocks_loaded )
         LoadBMEntrysTo( requested_block );
 
+    assert(requested_block < xblock_segment.size());
     if( regular_blocks )
         // regular blocks are all in one segment.
         return xblock_segment[0];
@@ -479,6 +480,7 @@
  * does it modify the state of the SysVirtualFile, other than to
  * flush the loaded block if it is dirty.
  */

comment:4 by Even Rouault, 5 years ago

Milestone: closed_because_of_github_migration
Resolution: wontfix
Status: newclosed

This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub. If you believe this ticket is still valid, you may file it to https://github.com/OSGeo/gdal/issues if it is not already reported there.

Note: See TracTickets for help on using tickets.