Opened 16 years ago

Closed 14 years ago

#1040 closed patch (fixed)

[PATCH] qgis crashes when I try to add RPF A.TOC file (also: RasterLite support)

Reported by: hamiltonsean69 Owned by: jef
Priority: major: does not work as expected Milestone: Version 2.0.0
Component: Rasters Version: Trunk
Keywords: RPF Cc: rouault
Must Fix for Release: Yes Platform: All
Platform Version: Awaiting user input: no

Description

When I try to add a raster layer and select RPF>A.TOC file the entire program closes out without any warning or anything. This occurs on both the windows version and Linux version that I am using. This map data is good. It was download striaght from NGA website on a secret network.

Attachments (2)

qgis_qgsrasterlayer_bug1040.patch (743 bytes ) - added by rouault 16 years ago.
diff (16.0 KB ) - added by jef 14 years ago.
patch to allow addition of raster from multilayer datasources like rasterlite

Download all attachments as: .zip

Change History (15)

comment:1 by hamiltonsean69, 16 years ago

Platform Version: Fedora Core 8
Version: HEAD0.9.1

comment:2 by rouault, 16 years ago

This still exists with 0.10.0, and this is not specifically due to the RPF A.TOC format, but the crash can happy with any raster format that declare subdatasets (HDF4, HDF5, OGDI raster, netCDF, RS2 and ADRG drivers are also concerned by this). The main raster has no data itself, but declares a list of subdatasets that can be opened by GDALOpen.

Here's the stack trace of the crash

Program received signal SIGABRT, Aborted.
[Switching to Thread -1280899392 (LWP 14925)]
0xffffe410 in __kernel_vsyscall ()
(gdb) bt
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb59fc875 in raise () from /lib/tls/i686/cmov/libc.so.6
#2  0xb59fe201 in abort () from /lib/tls/i686/cmov/libc.so.6
#3  0xb62f462a in CPLErrorV (eErrClass=CE_Fatal, err_no=10, fmt=0xb69b7f44 "Pointer '%s' is NULL in '%s'.\n", args=0xbfdd213c "<\177\233�\205\201\233�4\236\"�����")
    at cpl_error.cpp:233
#4  0xb62f46c4 in CPLError (eErrClass=CE_Fatal, err_no=10, fmt=0xb69b7f44 "Pointer '%s' is NULL in '%s'.\n") at cpl_error.cpp:133
#5  0xb62cff8d in GDALGetOverviewCount (hBand=0x0) at gdalrasterband.cpp:1855
#6  0xb7165862 in QgsRasterLayer::readFile () from /usr/lib/libqgis_core.so.0.10
#7  0xb716b572 in QgsRasterLayer::QgsRasterLayer () from /usr/lib/libqgis_core.so.0.10
#8  0x080fccc6 in QgisApp::addRasterLayer ()
#9  0x08104abf in QgisApp::openLayer ()
#10 0x080f9f5f in main ()

In fact, this is due to the following code snipet that makes the assumption that the return of GDALGetRasterBand(hDS, 1) will be non-NULL.

  //check f this file has pyramids
  GDALRasterBandH myGDALBand = GDALGetRasterBand( mGdalDataset, 1 ); //just use the first band
  if( GDALGetOverviewCount(myGDALBand) > 0 )
  {
    hasPyramidsFlag=true;
  }
  else
  {
    hasPyramidsFlag=false;
  }

The quickest fix is to apply the attached patch. In a longer term, it may be good to support subdatasets, by displaying the list of subdatasets to the user, as OpenEV does.

comment:3 by rouault, 16 years ago

Platform: FedoraAll
Platform Version: Fedora Core 8
Summary: qgis crashes when I try to add RPF A.TOC file[PATCH] qgis crashes when I try to add RPF A.TOC file

by rouault, 16 years ago

comment:4 by rouault, 16 years ago

Cc: warmerdam added

Frank,

I add you in CC as I don't know who to assign this. You might probably know better than me.

comment:5 by warmerdam, 16 years ago

Cc: rouault added; warmerdam removed
Owner: changed from nobody to warmerdam

I have incorporated a variation on this patch in trunk (r...) that also treats files without bands as invalid in the isValidRasterFileName().

Currently isValidRasterFileName() does not provide any mechanism to report an error to the user, so the user just sees "is not a supported dataset". I would also like to change this, but I will address this as a followup patch. Even is also quite right that some sort of subdataset selection dialog would be very desirable for datasets like this with subdatasets.

comment:6 by warmerdam, 16 years ago

Sorry, the last change was r8693.

comment:7 by warmerdam, 16 years ago

Resolution: fixed
Status: newclosed

I have commited a change in trunk (r8694) that improves error propagation for raster layer open failures. In particular isValidRasterFileName() now returns an error message if the filename is a raster, but just not supported for some particular reason.

I'd still like to do something about subdataset support, but this seems more involved and I'm not sure what to do. So I'm closing this particular ticket. Feel free to open a new ticket specifically requesting subdataset support as an enhancement.

comment:8 by pcav, 14 years ago

Milestone: Version 1.5.0
Must Fix for Release: NoYes
Priority: critical: causes crash or data corruptionmajor: does not work as expected
Resolution: fixed
Status: closedreopened
Version: 0.9.1HEAD

The same problem makes it impossible to open a RasterLite db with more than one raster layer, see: https://trac.osgeo.org/gdal/ticket/3568

For instance, this: http://www.gaia-gis.it/planet_earth.sqlite fails: /home/paolo/Desktop/planet_earth.sqlite is not a supported raster data source This raster file has no bands and is invalid as a raster layer. Gdal can read it:

$ gdalinfo /media/disk/planet_earth.sqlite

Driver: Rasterlite/Rasterlite
Files: 
Size is 512, 512
Coordinate System is `'
Subdatasets:
  SUBDATASET_1_NAME=RASTERLITE:/media/disk/planet_earth.sqlite,table=elevation
  SUBDATASET_1_DESC=RASTERLITE:/media/disk/planet_earth.sqlite,table=elevation
  
SUBDATASET_2_NAME=RASTERLITE:/media/disk/planet_earth.sqlite,table=population
  
SUBDATASET_2_DESC=RASTERLITE:/media/disk/planet_earth.sqlite,table=population
  
SUBDATASET_3_NAME=RASTERLITE:/media/disk/planet_earth.sqlite,table=shaded_color
  
SUBDATASET_3_DESC=RASTERLITE:/media/disk/planet_earth.sqlite,table=shaded_color
  
SUBDATASET_4_NAME=RASTERLITE:/media/disk/planet_earth.sqlite,table=shaded_gray
  
SUBDATASET_4_DESC=RASTERLITE:/media/disk/planet_earth.sqlite,table=shaded_gray
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  512.0)
Upper Right (  512.0,    0.0)
Lower Right (  512.0,  512.0)
Center      (  256.0,  256.0)


$ gdalinfo RASTERLITE:/media/disk/planet_earth.sqlite,table=elevation

Driver: Rasterlite/Rasterlite
Files: /media/disk/planet_earth.sqlite
Size is 43200, 18000
Coordinate System is:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0,
        AUTHORITY["EPSG","8901"]],
    UNIT["degree",0.01745329251994328,
        AUTHORITY["EPSG","9122"]],
    AUTHORITY["EPSG","4326"]]
Origin = (-180.000000000000000,89.999999999999972)
Pixel Size = (0.008333333333300,-0.008333333333300)
Metadata:
  TILE_FORMAT=JPEG
Image Structure Metadata:
  INTERLEAVE=PIXEL
  COMPRESSION=JPEG
Corner Coordinates:
Upper Left  (-180.0000000,  90.0000000) (180d 0'0.00"W, 90d 0'0.00"N)
Lower Left  (-180.0000000, -60.0000000) (180d 0'0.00"W, 60d 0'0.00"S)
Upper Right ( 180.0000000,  90.0000000) (180d 0'0.00"E, 90d 0'0.00"N)
Lower Right ( 180.0000000, -60.0000000) (180d 0'0.00"E, 60d 0'0.00"S)
Center      (  -0.0000000,  15.0000000) (  0d 0'0.00"W, 15d 0'0.00"N)
Band 1 Block=400x500 Type=Byte, ColorInterp=Red
  Overviews: 21600x9000, 10800x4500, 5400x2250, 2700x1125, 1350x563, 675x281, 
338x141
Band 2 Block=400x500 Type=Byte, ColorInterp=Green
  Overviews: 21600x9000, 10800x4500, 5400x2250, 2700x1125, 1350x563, 675x281, 
338x141
Band 3 Block=400x500 Type=Byte, ColorInterp=Blue
  Overviews: 21600x9000, 10800x4500, 5400x2250, 2700x1125, 1350x563, 675x281, 
338x141

So this is a QGIS limitation : it cannot handle images with subdatasets.

comment:9 by pcav, 14 years ago

Milestone: Version 1.5.0Version 2.0.0
Summary: [PATCH] qgis crashes when I try to add RPF A.TOC file[PATCH] qgis crashes when I try to add RPF A.TOC file (also: RasterLite support)

comment:10 by pcav, 14 years ago

Type: defectbug

by jef, 14 years ago

Attachment: diff added

patch to allow addition of raster from multilayer datasources like rasterlite

comment:11 by jef, 14 years ago

Owner: changed from warmerdam to jef
Status: reopenednew
Type: bugpatch

comment:12 by jef, 14 years ago

Status: newassigned

comment:13 by jef, 14 years ago

Resolution: fixed
Status: assignedclosed

applied in r14064.

Note: See TracTickets for help on using tickets.