[Gdal-dev] gdal_translate failed in debug

Frank Warmerdam warmerdam at pobox.com
Tue Jan 23 12:29:27 EST 2007

Gennady Khokhorin wrote:
> Hello, all.
> Debugging gdal_translate got a "User breakpoint" dialog box with diagnostic:
> HEAP[gdal_translate.exe]: Invalid Address specified to RtlFreeHeap( 2f0000, bf10c8 )
> It happens at this call:
> GDALClose( (GDALDatasetH) poVDS ); (line 937, gdal_translate.cpp)
> Looks like VRTSimpleSource::~VRTSimpleSource() is dereferencing 3 bands in GDALClose() 
> and fails on delete poDS (line 1847, gdaldataset.cpp).
> Should it be used VSIFree(papoBands[i]) method instead of delete papoBands[i]; ?


Delete is the appropriate operator for papoBands[i] - these are C++ objects
of base type GDALRasterBand and are allocated with new.

I believe you are seeing this problem because the VRTDataset() is created
with "new" in gdal_translate.cpp, but release with delete inside the
GDAL DLL.  The problem is that in some ways of building on windows you
end up with distinct heaps for the .exe and the GDAL DLL.

I think the solution would be to modify gdal_translate.cpp to call
"delete poVDS" instead of GDALClose().

I'd appreciate it if you could file a bug with your finds, and
my analysis and we will fix this for GDAL 1.4.1.  I may take
a slightly different approach to avoid even calling "new VRTDataset()"
in gdal_translate since this "direct access" is inherently dangerous
due to it being very different from normal operations with GDAL.

Best regards,

> Output result is fine. Release version works fine.
> Image is rgb 3 bands 8 bits/sample. Below is output from gdalinfo
> I'm with gdal 1.4.0, no dwg/dxf support, msvc60 + win2K

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    | President OSGeo, http://osgeo.org

More information about the Gdal-dev mailing list