Crash loading SHP file from read-only location

classic Classic list List threaded Threaded
5 messages Options
David David
Reply | Threaded
Open this post in threaded view
|

Crash loading SHP file from read-only location

We have a .earth file that includes a feature layer using a .shp file to draw county borders.  When our product was installed to a location that users would only have read-only access to, it would crash on startup.  We traced the problem to the feature layer with the .shp file.  If we remove that layer, or move the .shp file somewhere with write permissions, everything is fine.  I've looked at a strack trace, and ultimately the crash is coming from within GDAL after calling OGROpen in the feature_ogr driver, but beyond that I haven't been able to identify why it's crashing.  Below is a copy of the .earth file and the software versions we're using.  Any ideas what the problem might be?


OSG Version: 3.4.0
OSG Earth Version: 2.7
GDAL Version: 2.3.1

<map name="3D Globe" type="geocentric" version="2">
 
    <options>
        <profile>spherical-mercator</profile>
        <lighting>true</lighting>
        <terrain engine="quadtree" range_mode="PIXEL_SIZE_ON_SCREEN" tile_pixel_size="256" vertical_scale="3"/>
    </options>
    
    <!-- NOTE: the "quadkey_layered" driver is a custom driver very similar to
    the "quadkey" driver that comes with osgEarth except that it supports the
    additional {lod} property that allows you to organized your quad tree
    imagery in subfolders based on the level. -->
    <image name="imagery" driver="quadkey_layered">
        <url>\\terrain\level_{lod}\a{key}.jpg</url>
    </image>
    
    <model name="country_borders" driver="feature_geom">

        <!-- Configure the OGR feature driver to read the shapefile -->
        <features name="world" driver="ogr">
            <url>..\shp\countries.shp</url>
            <profile>global-geodetic</profile>
        </features>
        
        <!-- Appearance details -->
        <styles>
            <style type="text/css">
                states {
                   stroke:          #ffff0080;
                   stroke-width:  1.0;
                   render-lighting: false;
                   render-depth-offset-min-bias: 1000;
                   altitude-clamping: terrain;
                   altitude-technique: map;
                }                    
            </style>
        </styles>
    </model>
</map>
David David
Reply | Threaded
Open this post in threaded view
|

Re: Crash loading SHP file from read-only location

While I don't know exactly what the problem is, it appears to be a bug in GDAL, not osgEarth.  We are seeing the same crash loading read only SHP files using the same version of GDAL but without using osgEarth or OSG.  I guess we'll try a different version of GDAL, and if we still see the problem, try digging into the source next.
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Crash loading SHP file from read-only location

Very odd. Let us know if you find a root cause.

BTW, you can standardize on forward slashes in your pathnames as a best practice. OsgEarth will figure it out 🙂
Glenn Waldron / Pelican Mapping
David David
Reply | Threaded
Open this post in threaded view
|

Re: Crash loading SHP file from read-only location

So, it turns out it's not a bug in osgEarth or GDAL.  There's apparently a setting that you can enable in GDAL that forces it to always try to write the .shx file that goes with a .shp file, even if it already exists, and we had apparently turned that setting on.  Removing that line from our code fixed the problem.

Nothing to see here...move along.
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Crash loading SHP file from read-only location

OK great. Thanks for sharing the solution! :)
Glenn Waldron / Pelican Mapping