[Gdal-dev] Problems with reading Spatial reference on Shape files

Richard Matsunaga richard at waypointinfo.com
Thu Sep 27 17:16:40 EDT 2007


Hi all,
 
I'm somewhat at wit's end with this problem and am really only fishing for
ideas.
 
The problem occurs when releasing the DataSource for an ESRI Shape file
after getting its spatial reference. The same code works fine with MapInfo
files.
 
My code is very simple in this case and only occurs when running as part of
a ASP.NET web site. If I strip out any content it still fails. This same
code works fine in a simple console app, as well as running the exact same
library code using NUnit tests. But other than the usual ASP.NET page
lifecycle stuff, there isn't anything else happening with unmanaged code
such as GDAL/OGR that could be fingered as a memory overrun culprit.
 
 
using (DataSource ds = Ogr.OpenShared(fileName, 0))
{
    using (Layer layer = ds.GetLayerByIndex(0))
    {
        using (SpatialReference srs = layer.GetSpatialRef())
        {
        }
    }
}   <--- exception occurs here (or on Dispose if I explicitly call it)

 

Using an point file:
 
[AccessViolationException: Attempted to read or write protected memory. This
is often an indication that other memory is corrupt.]
   OSGeo.OGR.OgrPINVOKE.delete_DataSource(HandleRef jarg1) +0
   OSGeo.OGR.DataSource.Dispose() +191

Using a polygon shape file (converted from a MapInfo tab file using ogr2ogr)
I get the following:
 
[OverflowException: Arithmetic operation resulted in an overflow.]
   OSGeo.OGR.OgrPINVOKE.delete_DataSource(HandleRef jarg1) +0
   OSGeo.OGR.DataSource.Dispose() +191

In both cases, the Wrapper.Name is corrupted - the first few characters in
the file path are garbage. I guess this is the symptom of the problem, but I
can't guess at the root cause. The handle is not null and otherwise looks
fine.
 
My next step is try to reproduce with a basic no-content ASP.NET web site.
 
Any ideas are welcome.
 
Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20070927/95a62866/attachment.html


More information about the Gdal-dev mailing list