[gdal-dev] Crash: [GDAL 1.10dev] empty shapefile with spatial index

Dennis Gocke dengo at gmx.net
Fri Apr 5 04:12:13 PDT 2013


Wow, that was fast, Thanks.

I just remembered something else I stumbled upon related to the shapefile
driver.

It's more of an user/programmer error, but it might be interesting
nonetheless.
After deleting features we normally Execute the "REPACK LayerName".
The problem is that when LayerName is not in the correct case sensitivity,
it does not work.
Which is understandable because on non-windows filesystems there might
actually be different files.

The funny thing is, when you open the DataSource/Layer with incorrect case
sensitivity in the filepath, it first seems that everything is fine, but
when you call "REPACK " + layer.GetName() it does not work, because
layer.GetName() will return the same wrong case sensitivity that was
provided when the DataSource was opened.

And there is another thing. Once someone had managed to have the different
files belonging to the same shapefile (shp, dbf) in different case
sensitivies (e.g. data.shp and DATA.dbf). As above everything except the
REPACK seemed to work fine, but the REPACK did not work. I think in this
case "REPACK data"/"REPACK DATA" either did nothing like above or it even
threw an error. That depended on how the datasource was opened with
Open("DATA.shp", 1) or Open("data.shp", 1). But in this case neither
combination worked.

Let me know if you would like more details on this.

Cheers,
Dennis


On Fri, Apr 5, 2013 at 12:07 PM, Even Rouault
<even.rouault at mines-paris.org>wrote:

> Selon Dennis Gocke <dengo at gmx.net>:
>
> > Hi,
> >
> > I've encountered a serious problem with an empty shapefile (no features)
> > that already has sbn, sbx files generated. When trying to create a
> feature
> > there is an Access Violation and the program crashes without any chance
> to
> > catch the exception.
> > The shapefile was exported with ArcCatalog, but the same happens when
> > creating an empty shapefile with OGR and then creating spatial index on
> it
> > with ArcCatalog.
> >
> > Trying "DROP SPATIAL INDEX ON.." in OGR also produces the same crash.
> >
> > When manually deleting the sbn, sbx files before opening the shapefile
> with
> > OGR, everything works fine.
> >
> > I am using the C# wrapper, but I am sure the problem is in OGR itself.
> > The lines that can be used to reproduce the crash:
> >
> > DataSource ds = Ogr.Open(@"D:\test\IndustryA_O.shp", 1);
> > Layer layer = ds.GetLayerByIndex(0);
> > FeatureDefn featureDefn = layer.GetLayerDefn();
> > Feature newFeature = new Feature(featureDefn);
> > layer.CreateFeature(newFeature);  // <-- Crash
> >
> > Using GDAL 1.9.2 does not produce the crash, but this was to be expected
> > because 1.9.2 just ignores the spatial index.
> >
> > I've also attached the shapefile. Hopefully this works with the mailing
> > list.
>
> Thanks for the precise report. I've managed to reproduce and committed a
> fix in
> r25862.
>
> >
> > Regards,
> > Dennis
> >
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130405/56279a06/attachment.html>


More information about the gdal-dev mailing list