[gdal-dev] Need help if OGR C-API

Even Rouault even.rouault at mines-paris.org
Fri Sep 3 14:20:55 EDT 2010


Stephen

did you read : 
http://gdal.org/ogr/ogr__api_8h.html#7b67ea4ab5892c6720460dc7f66eca2d ?

You'll know the cause of the crash afterwards ;-)

Le vendredi 03 septembre 2010 20:12:51, Stephen Woodbridge a écrit :
> Even,
> 
> Here is my test program:
> 
> $ cat testogr.c
> #include "ogr_api.h"
> 
> int main() {
>      OGRDataSourceH hDSin;
>      OGRLayerH hLayerIn;
>      OGRFeatureDefnH hFDefnIn;
>      OGRwkbGeometryType layerGeomType;
> 
>      OGRRegisterAll();
> 
>      hDSin = OGROpen( "/u/data/routeloops-v2/25/25017/Streets.shp",
> FALSE, NULL );
>      hLayerIn = OGR_DS_GetLayerByName( hDSin, "Streets" );
> 
>      hFDefnIn = OGR_L_GetLayerDefn( hLayerIn );
>      layerGeomType = OGR_FD_GetGeomType( hFDefnIn );
>      printf("GeometryType: %s\n", OGRGeometryTypeToName( layerGeomType ));
> 
>      OGR_FD_Release( hFDefnIn );
>      OGR_DS_Destroy( hDSin );
> }
> 
> $ gcc -g -o testogr testogr.c  -I/usr/local/include/gdal -lgdal -lm
> 
> It reports GeometryType correctly and then segvs :(
> 
> woodbri at mappy:~/work$ gdb ./testogr
> GNU gdb 6.8-debian
> Copyright (C) 2008 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later
> <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "x86_64-linux-gnu"...
> (gdb) run
> Starting program: /home/woodbri/work/testogr
> [Thread debugging using libthread_db enabled]
> warning: Lowest section in /usr/lib/libicudata.so.38 is .hash at
> 0000000000000120
> GeometryType: Line String
> [New Thread 0x7f361a0bc710 (LWP 30585)]
> 
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 0x7f361a0bc710 (LWP 30585)]
> 0x0000000000000031 in ?? ()
> (gdb) bt
> #0  0x0000000000000031 in ?? ()
> #1  0x00007f3619a2f190 in ~OGRShapeLayer (this=0x605a40)
>      at ogrshapelayer.cpp:105
> #2  0x00007f3619a2c63f in ~OGRShapeDataSource (this=0x604330)
>      at ogrshapedatasource.cpp:62
> #3  0x0000000000400958 in main () at testogr.c:19


More information about the gdal-dev mailing list