Opened 17 months ago

Closed 17 months ago

Last modified 17 months ago

#6337 closed defect (fixed)

gdalinfo and gdal_translate seg faulting for unsigned short variables in netcdf file

Reported by: brodzik Owned by: warmerdam
Priority: normal Milestone: 1.11.5
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords: netcdf unsigned short


I am using gdalinfo and gdal_translate to extract information from netCDF files with multiple variables into individual geoTiffs. The netCDF files contain 5 "SUBDATASETS" variables, as follows from gdalinfo:

  SUBDATASET_1_DESC=[1x720x720] brightness_temperature (16-bit unsigned integer)
  SUBDATASET_2_DESC=[1x720x720] TB_num_samples (8-bit unsigned integer)
  SUBDATASET_3_DESC=[1x720x720] TB_std_dev (16-bit unsigned integer)
  SUBDATASET_4_DESC=[1x720x720] Incidence_angle (16-bit integer)
  SUBDATASET_5_DESC=[1x720x720] TB_time (16-bit integer)

Note that there are 2 16-bit unsigned integer data sets, 1 8-bit unsigned int and 2 16-bit signed integers.

Calls to gdalinfo and gdal_translate both seg fault for the 16-bit unsigned ints, but work as I would expect for the other 3 variables. Here is a sample of how I am calling gdalinfo:

vagrant@vigloo:/projects/CHARIS/tmp_mjb/2003001/2003001$ gdalinfo NETCDF:"":TB
Segmentation fault (core dumped)
vagrant@vigloo:/projects/CHARIS/tmp_mjb/2003001/2003001$ gdalinfo NETCDF:"":TB_num_samples
Driver: netCDF/Network Common Data Format
Files: of gdalinfo output snipped...)

I have produced this behavior using GDAL 2.0.0 built on Ubuntu and GDAL 1.11.2 built on MacOSX.

I would be happy to provide the netCDF file for testing if you need it. It's nearly 1 MB in size, so I wasn't sure if it would be wise to attach it to a trac ticket.

Change History (7)

comment:1 Changed 17 months ago by Even Rouault

You can write here the URL if it is a publicly accessible resource. Otherwise send it to me by email at even.rouault at

comment:2 Changed 17 months ago by brodzik

I just emailed it to Even.

comment:3 Changed 17 months ago by Even Rouault

Component: defaultGDAL_Raster
Keywords: netcdf unsigned short added

trunk r33186 "netCDF: add support for reading NC4 unsigned short attributes and variables (#6337)"

Partial backport in older branches to avoid crash (data will be read as Float32): branches/2.0 r33187, branches/1.11 r33188 : "netCDF: do not crash on NC4 unsigned short attributes (#6337)"

comment:4 Changed 17 months ago by Even Rouault

trunk r33190 "netCDF: disable code used in creation path of uint16 since there are other parts required to make this work"

comment:5 Changed 17 months ago by Even Rouault

Milestone: 1.11.5
Resolution: fixed
Status: newclosed

comment:6 Changed 17 months ago by brodzik

Even, How do I go about obtaining this fix?

comment:7 Changed 17 months ago by Even Rouault

You have to checkout one of the SVN branch (1.11, 2.0 or trunk) and build from sources.

Note: See TracTickets for help on using tickets.