[Gdal-dev] Crash in VC++ in GDALClose(VRTDataset*)

Garvan Keeley garvank at optech.on.ca
Tue Mar 25 15:11:40 EST 2003

I am trying to use some of the code from gdal_translate, but I found it was
crashing when built under Visual Studio .Net (unmanaged C++).

Here is a small C++ console app that crashes in the function GDALClose().
Any idea what might be causing this?

// assume library paths and linker options are set correctly
// i.e. add the gdal source tree to additional include dirs and
// gdal_i.lib added to linker dependencies

#include "gdal.h"
#include "frmts\vrt\vrtdataset.h"

int _tmain(int argc, _TCHAR* argv[])
	VRTDataset* poVDS = new VRTDataset( 100, 100 );
	GDALClose( (GDALDatasetH) poVDS );

The above function crashes with an "Unhandled exception" when the VRTDataset
pointer is deleted (at line 336 of gdalopen.cpp):

    for( i = 0; i < nSharedDatasetCount; i++ )
          delete poDS; <-- crashes here

	return 0;

Garvan Keeley
Tel: 416.661.5904 x441

More information about the Gdal-dev mailing list