[Gdal-dev] segfault in SHPCreateObject

Frank Warmerdam fwarmerdam at gmail.com
Tue Sep 13 10:22:35 EDT 2005


On 9/13/05, Ari Jolma <ari.jolma at tkk.fi> wrote:
> Sorry for making multiple threads but my thunderbird tends to classify
> gdal-dev as junk and I did not notice this before.

Ari,

/me expresses shock that gdal-dev would be considered junk!
 
> Ok, but that was not the source of the segfault I think. In this case
> the layer is a brand new, just constructed. So the correct (?) way to
> create a new layer  is to:
> 
> create layer
> CreateFields into the layer
> featuredefn = layer.GetLayerDefn
> use this featuredefn for all features which are CreateFeature'd into the
> layer

This is the correct sequence.   

I do think that OGR ought to do some more run-time
checking that features use the right featuredefn.  
If you point out particular cases that don't currently I 
will look into it.

Unfortunately, due to the OGR architecture where 
methods such as CreateFeature() are directly overridden
by the format specific classes it is hard to check 
pre-conditions without incorporating the code into all
the driver implementations.  I could put some extra
checking in the C cover functions which would help
applications using the C interface (and all the swig bindings). 
Perhaps that would be a better angle.
 
Unfortunately that leaves us in the case where the C++
interface becomes uniquely dangerous. 

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    | Geospatial Programmer for Rent




More information about the Gdal-dev mailing list