[Gdal-dev] about VRTDataset
Fu Chen
fchen at ne.rsgs.ac.cn
Mon Oct 27 20:03:41 EST 2003
Frank,
Yeah, it is the trouble of different generate mode. This is the first time I face this problem in my life. Does Microsoft have any idea to bypass this trap? I formerly believe using dll would cooperate between different generate mode. Now it is a mistake. I hope you can note this in the document of GDAL. Somebody using VC will face the same problem, I think.
BTW, do you know how to debug the gdal11.dll in VC IDE? Up to now, I use CPLDebug to do my work. It seems waste the ability of IDE. But I really don't know how to debug a dll outside of workspace built by command line nmake.
Thank!!
----- Original Message -----
From: "Frank Warmerdam" <warmerdam at pobox.com>
To: <gdal-dev at remotesensing.org>
Sent: Monday, October 27, 2003 9:04 PM
Subject: Re: [Gdal-dev] about VRTDataset
> 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
>
>
> _______________________________________________
> Gdal-dev mailing list
> Gdal-dev at remotesensing.org
> http://remotesensing.org/mailman/listinfo/gdal-dev
More information about the Gdal-dev
mailing list