Opened 15 years ago

Closed 15 years ago

#2797 closed defect (fixed)

GDALOpenShared may crashes if dataset description is not the dataset filename

Reported by: ftrastour Owned by: Even 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 (2)

comment:1 by Even Rouault, 15 years ago

Cc: warmerdam added
Milestone: 1.6.1
Owner: changed from warmerdam to Even Rouault
Version: unspecified1.6.0

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.

comment:2 by Even Rouault, 15 years ago

Resolution: fixed
Status: newclosed

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

Note: See TracTickets for help on using tickets.