Ticket #2797 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

GDALOpenShared may crashes if dataset description is not the dataset filename

Reported by: ftrastour Owned by: rouault
Priority: normal Milestone: 1.6.1
Component: GDAL_Raster Version: 1.6.0
Severity: normal Keywords:
Cc: warmerdam

Description

GDALOpenShared crashes when called twice on the same dataset if the string returned by GetDescription? is not the filename used to open the dataset.

GDALOpenShared sometimes uses the filename to register a dataset :

*** gdaldataset.cpp/line 2017

sStruct.pszDescription = (char*) pszFilename;

and sometimes the string returnd by GetDescription? :

*** gdaldataset.cpp/line 1031

psStruct->pszDescription = CPLStrdup(GetDescription?());

Change History

Changed 3 years ago by rouault

  • cc warmerdam added
  • owner changed from warmerdam to rouault
  • version changed from unspecified to 1.6.0
  • milestone set to 1.6.1

I'll take care of this, as it is due to a change in 1.6.0 in the way we are managing the list of shared dataset (the change was to enable GDALOpen/Close to have ~ O(1) performance versus O(n) previously where n is the number of currently opened datasets).

However note that the documentation of GDALOpenShared has always said :

 * In particular, GDALOpenShared() will first consult it's list of currently
 * open and shared GDALDataset's, and if the GetDescription() name for one
 * exactly matches the pszFilename passed to GDALOpenShared() it will be
 * referenced and returned.

I've also checked GDAL 1.5.X code, and GDALOpenShared() would not work as expected if the filename was different from the dataset description returned by GetDescription?().

I'll just avoid the crash and issue a warning when the situation is detected.

Changed 3 years ago by rouault

  • status changed from new to closed
  • resolution set to fixed

Fixed in trunk in r16159 and in branches/1.6 in r16160

Note: See TracTickets for help on using tickets.