[gdal-dev] ogr2ogr bug with dwg file

Even Rouault even.rouault at mines-paris.org
Thu Jul 11 10:43:43 PDT 2013


Le jeudi 11 juillet 2013 09:33:36, Xian Chen a écrit :
> Hi all,
> 
> Finally I've got a chance to report something after one-month silence as a
> newcomer in the community.
> After running ogr2ogr (on Windows 7) to convert a dwg file into shape
> files, I received an error message as follows:
> /    Warning 6: Normalized/laundered field name: 'ExtendedEntity' to
> 'ExtendedEn'
>     Warning 6: Normalized/laundered field name: 'EntityHandle' to
> 'EntityHand'
>     ERROR 1: Attempt to write non-linestring (POINT) geometry to ARC type
> shapefile.
> 
>     ERROR 1: Terminating translation prematurely after failed
>     translation of layer entities (use -skipfailures to skip errors)/
> 
> And then the application exited abnormally.  I read the source code and
> found that the last error message was produced by an error from
> TranslateLayer(). The application terminated there without calling
> OGRCleanupAll()
> 
> Therefore I tested reading dwg file on OGR. My conclusion is that
> OGRCleanupAll() has to be called explicitly before termination of the whole
> application, otherwise an abnormal termination (due to stack overflow??)
> will occur.

Hi Xian,

Interesting.

Yes calling OGRCleanupAll() is a best practice, and probably that even the 
error code paths in the utilities should call it, but it shouldn't be 
compulsory to call it.

Looking at the code of the DWG driver, I see that the driver has indeed code 
in its destructor to call the odUninitialize() function. When you call 
OGRCleanupAll() then this code is called. But GDAL has also a DLL clean-up 
code that will call OGRCleanupAll(). I suspect that in that case, some C++ 
automatic objects normally cleaned by odUninitialize() have already been 
destroyed, and at the time odUninitialize() is called, it will access them at 
the time where they are no longer available. Hence the crash.

Being not in position to test it myself, in order to confirm my above guess, 
could you revert your changes in ogr2ogr.cpp and test the attached patch 
(based on GDAL trunk) ?

Best regards,

Even

> 
> --
> View this message in context:
> http://osgeo-org.1560.x6.nabble.com/ogr2ogr-bug-with-dwg-file-tp5065611.ht
> ml Sent from the GDAL - Dev mailing list archive at Nabble.com.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
Geospatial professional services
http://even.rouault.free.fr/services.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: disable_dwg_destructor.patch
Type: text/x-patch
Size: 1041 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130711/393e781d/attachment.bin>


More information about the gdal-dev mailing list