[Gdal-dev] about VRTDataset

Frank Warmerdam warmerdam at pobox.com
Mon Oct 27 08:04:23 EST 2003


Fu Chen wrote:

> Frank,
> 
> I also find it very weird. I compile gdal and my test program on two PC has the same result. 
> The gdal is cleaned by "nmake /f makefile.vc clean", and rebuild several times. But still has trouble.
> even this code won't work
> 
> #include "cpl_vsi.h"
> #include "cpl_conv.h"
> #include "cpl_string.h"
> #include "gdal_priv.h"
> #include "ogr_spatialref.h"
> #include "vrt/vrtdataset.h"
> 
> void main()
> {
>     //GDALAllRegister();
>     VRTDataset *poVDS;
>     poVDS = new VRTDataset( 100, 100);
>  //GDALDumpOpenDatasets( stderr );
>  delete poVDS;
> }
> 
> The Debug said
> HEAP[translate.exe]: Invalid Address specified to RtlFreeHeap( 12b0000, 12c3a28 )
> at the end of delete statement.
> 
> I really don't know what's wrong. Maybe a bug in vc compiler :<

Fu Chen,

OK, I see the problem is related to having multiple memory allocation heaps.
It seems that the new is done out of the gdal11.dll heap but the delete is
assuming that the memory should be freed into your mainline heap.

The gdal_translate.cpp code does "GDALClose((GDALDatasetH) poVDS)" to close
the virtual dataset.  Similarly there are seperate sets of file handles for
stuff like stdout and stderr between your mainline and gdal11.dll, so the
dump open datasets fails when you pass in a mainline "stderr".

You can build gdal11.dll and your mainline with the C runtime library using
the /MD commandline switch and then this problem will go away.  Or be careful
about it in your code (which can be hard).

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent





More information about the Gdal-dev mailing list