Opened 9 months ago

Closed 9 months ago

Last modified 9 months ago

#6645 closed defect (fixed)

segfault in NCDFGet1DVar

Reported by: Kurt Schwehr Owned by: warmerdam
Priority: normal Milestone: 2.0.4
Component: default Version: 2.0.0
Severity: major Keywords: netcdf
Cc:

Description

This issue looks to have been around for at least 2 years. It could well be a netcdf bug and not GDAL, but if it is, can we keep GDAL from crashing?

From GDAL at r35350 in trunk on ubuntu 14.04:

gdb gdalinfo
set args air.sig995.2014.nc
(gdb) r
Starting program: /home/schwehr/src/gdal/inst/bin/gdalinfo air.sig995.2014.nc

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6de7cc1 in NCDFGet1DVar (nCdfId=65536, nVarId=2, pszValue=0x7fffffffd348) at netcdfdataset.cpp:8343
8343                    CPLsnprintf( szTemp, sizeof(szTemp), "%.16g,", pdfTemp[m] );
(gdb) bt
#0  0x00007ffff6de7cc1 in NCDFGet1DVar (nCdfId=65536, nVarId=2, pszValue=0x7fffffffd348) at netcdfdataset.cpp:8343
#1  0x00007ffff6de03dd in netCDFDataset::Open (poOpenInfo=0x7fffffffdb20) at netcdfdataset.cpp:6322
#2  0x00007ffff7073c27 in GDALOpenEx (pszFilename=0x6560f0 "air.sig995.2014.nc",
    nOpenFlags=66, papszAllowedDrivers=0x0, papszOpenOptions=0x0, papszSiblingFiles=0x0) at gdaldataset.cpp:2757
#3  0x000000000040146f in main (argc=2, argv=0x655f80) at gdalinfo_bin.cpp:132

libs:

ldd /home/schwehr/src/gdal/inst/bin/gdalinfo | egrep 'netcdf|hdf'
	libnetcdf.so.7 => /usr/lib/libnetcdf.so.7 (0x00007f6f200f6000)
	libhdf5.so.7 => /usr/lib/x86_64-linux-gnu/libhdf5.so.7 (0x00007f6f1fc5a000)
	libmfhdfalt.so.0 => /usr/lib/libmfhdfalt.so.0 (0x00007f6f1fa29000)
	libhdf5_hl.so.7 => /usr/lib/x86_64-linux-gnu/libhdf5_hl.so.7 (0x00007f6f1ad8b000)
dpkg -l | grep '^ii' | egrep 'netcdf|hdf' | grep dev | cut -c-80
ii  libhdf4-alt-dev                                             4.2r10-0ubuntu1 
ii  libhdf5-dev                                                 1.8.11-5ubuntu7 
ii  libhdf5-serial-dev                                          1.8.11-5ubuntu7 
ii  libhdfeos-dev                                               2.17v1.00.dfsg.1
ii  libnetcdf-dev                                               1:4.1.3-7ubuntu2

I haven't been able to try with a newer version of netcdf.

Change History (5)

comment:1 Changed 9 months ago by Kurt Schwehr

A quick ncdump does not crash, but that probably doesn't mean much.

ncdump -c air.sig995.2014.nc
netcdf air.sig995.2014 {
dimensions:
	lat = 73 ;
	lon = 144 ;
	time = UNLIMITED ; // (0 currently)
variables:
	float lat(lat) ;
		lat:units = "degrees_north" ;
		lat:actual_range = 90.f, -90.f ;
		lat:long_name = "Latitude" ;
		lat:standard_name = "latitude" ;
		lat:axis = "Y" ;
	float lon(lon) ;
		lon:units = "degrees_east" ;
		lon:long_name = "Longitude" ;
		lon:actual_range = 0.f, 357.5f ;
		lon:standard_name = "longitude" ;
		lon:axis = "X" ;
	double time(time) ;
		time:units = "hours since 1-1-1 00:00:0.0" ;
		time:long_name = "Time" ;
		time:actual_range = 17645640., 17645634. ;
		time:delta_t = "0000-00-00 06:00:00" ;
		time:standard_name = "time" ;
		time:axis = "T" ;
	short air(time, lat, lon) ;
		air:long_name = "4xDaily Air temperature at sigma level 995" ;
		air:unpacked_valid_range = 185.16f, 331.16f ;
		air:actual_range = 331.16f, 185.16f ;
		air:units = "degK" ;
		air:add_offset = 512.81f ;
		air:scale_factor = 0.01f ;
		air:missing_value = 32766s ;
		air:precision = 2s ;
		air:least_significant_digit = 1s ;
		air:GRIB_id = 11s ;
		air:GRIB_name = "TMP" ;
		air:var_desc = "Air temperature" ;
		air:dataset = "NMC Reanalysis" ;
		air:level_desc = "Surface" ;
		air:statistic = "Individual Obs" ;
		air:parent_stat = "Other" ;
		air:valid_range = -32765s, -18165s ;

// global attributes:
		:Conventions = "COARDS" ;
		:title = "4x daily NMC reanalysis (2014)" ;
		:history = "created 2013/12 by Hoop (netCDF2.3)" ;
		:description = "Data is from NMC initialized reanalysis\n",
			"(4x/day).  These are the 0.9950 sigma level values." ;
		:platform = "Model" ;
		:references = "http://www.esrl.noaa.gov/psd/data/gridded/data.ncep.reanalysis.html" ;
data:

 lat = 90, 87.5, 85, 82.5, 80, 77.5, 75, 72.5, 70, 67.5, 65, 62.5, 60, 57.5, 
    55, 52.5, 50, 47.5, 45, 42.5, 40, 37.5, 35, 32.5, 30, 27.5, 25, 22.5, 20, 
    17.5, 15, 12.5, 10, 7.5, 5, 2.5, 0, -2.5, -5, -7.5, -10, -12.5, -15, 
    -17.5, -20, -22.5, -25, -27.5, -30, -32.5, -35, -37.5, -40, -42.5, -45, 
    -47.5, -50, -52.5, -55, -57.5, -60, -62.5, -65, -67.5, -70, -72.5, -75, 
    -77.5, -80, -82.5, -85, -87.5, -90 ;

 lon = 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, 22.5, 25, 27.5, 30, 32.5, 35, 
    37.5, 40, 42.5, 45, 47.5, 50, 52.5, 55, 57.5, 60, 62.5, 65, 67.5, 70, 
    72.5, 75, 77.5, 80, 82.5, 85, 87.5, 90, 92.5, 95, 97.5, 100, 102.5, 105, 
    107.5, 110, 112.5, 115, 117.5, 120, 122.5, 125, 127.5, 130, 132.5, 135, 
    137.5, 140, 142.5, 145, 147.5, 150, 152.5, 155, 157.5, 160, 162.5, 165, 
    167.5, 170, 172.5, 175, 177.5, 180, 182.5, 185, 187.5, 190, 192.5, 195, 
    197.5, 200, 202.5, 205, 207.5, 210, 212.5, 215, 217.5, 220, 222.5, 225, 
    227.5, 230, 232.5, 235, 237.5, 240, 242.5, 245, 247.5, 250, 252.5, 255, 
    257.5, 260, 262.5, 265, 267.5, 270, 272.5, 275, 277.5, 280, 282.5, 285, 
    287.5, 290, 292.5, 295, 297.5, 300, 302.5, 305, 307.5, 310, 312.5, 315, 
    317.5, 320, 322.5, 325, 327.5, 330, 332.5, 335, 337.5, 340, 342.5, 345, 
    347.5, 350, 352.5, 355, 357.5 ;
}

comment:2 Changed 9 months ago by Even Rouault

Resolution: fixed
Status: newclosed

In 35359:

netCDF: fix crash on datasets with 1D variable with 0 record (fixes #6645)

comment:3 Changed 9 months ago by Even Rouault

In 35360:

netCDF: fix crash on datasets with 1D variable with 0 record (fixes #6645)

comment:4 Changed 9 months ago by Even Rouault

In 35361:

netCDF: fix crash on datasets with 1D variable with 0 record (fixes #6645)

comment:5 Changed 9 months ago by Even Rouault

Milestone: 2.0.4
Version: svn-trunk2.0.0
Note: See TracTickets for help on using tickets.