[osgeo4w-dev] Problems in using Perl wrappers with osgeo4w distro

Ari Jolma ari.jolma at tkk.fi
Sun Mar 16 17:01:50 EDT 2008

Frank Warmerdam kirjoitti:
> gdal15.dll is built with VC++ 7.1 (aka Visual Studio 2003).  I have 
> skimmed
> this in the perl bindings:
>   OGRGeometryShadow* CreateGeometryFromWkb( int len, char *bin_string,
>                                             OSRSpatialReferenceShadow 
> *reference=NULL ) {
>     void *geom;
>     OGRErr err = OGR_G_CreateFromWkb( (unsigned char *) bin_string,
>                                       reference,
>                                       &geom,
>                                       len );
>     if (err != 0 ) {
>        CPLError(CE_Failure, err, "%s", OGRErrMessages(err));
>        return NULL;
>     }
>     return (OGRGeometryShadow*) geom;
>   }

This is straight from ogr.i and is not perl specific. Similar wrapper 
exists for Wkt.

> I don't see any obvious likely issues, such as allocations and frees
> taking place out of different heaps.  Is it possible that var-args lists
> don't work compatibly between gcc and vc++?  If this turns out to be the
> case we may need to provide a non-varargs based error function.

This seems most likely. If I comment out the call to CPLError, the next 
thing it hits is another call to CPLError. Even CPLError calls "within" 
GDAL seem bad. If I create a geometry from good GML, everything is ok, 
but if I break the GML, there's a segfault. In the latter case CPLError 
is called by minixml (probably) and OGR_G_CreateFromGML, which is called 
by the wrapper, never returns.


> I would note that OGRErr values are not really expected as the second
> argument to CPLError().  You might almost be safer passing 
> CPLE_AppDefined
> in this situation, though I can't imagine that having any significance
> in this case.
> Lastly, you might want to confirm that OGRErrMessages(err) is non-NULL.
> Best regards,

Prof. Ari Jolma
Geoinformatiikka / Geoinformatics
Teknillinen Korkeakoulu / Helsinki University of Technology
tel: +358 9 451 3886 address: POBox 1200, 02015 TKK, Finland
Email: ari.jolma at tkk.fi URL: http://www.tkk.fi/~jolma

More information about the osgeo4w-dev mailing list