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

Frank Warmerdam warmerdam at pobox.com
Sun Mar 16 13:46:12 EDT 2008


Ari Jolma wrote:
> Hello,
> 
> I'm able to build Perl wrappers from GDAL 1.5 against the latest osgeo4w 
> binary release. I use MinGW (g++ is 3.4.5 with which my perl 5.10 is 
> also built). The link library is gdal_i.lib - it just needs to be 
> renamed to gdal.dll.a for perl to find and use it.
> 
> The module loads ok, and calls some functions ok from gdal15.ddl but 
> fails when calling CPLError. Debugging the ogr_wrap.cpp I see that 
> OGR_G_CreateFromWkb is called ok (but it returns deliberately an error), 
> OGRErrMessages(err) gives me correct error message, but then calling 
> CPLError(CE_Failure, err, "%s", OGRErrMessages(err)); never returns and 
> Windows pops up the "has encountered a problem" dialog. gdb says that 
> there is a Segmentation fault and the stack looks corrupt.
> 
> I wonder what could be the problem and how to even study what's the real 
> problem.
> 
> With what compiler is gdal15.dll built?

Ari,

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;
   }

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.

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,
-- 
---------------------------------------+--------------------------------------
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 osgeo4w-dev mailing list