Ah ok, but I wasn't refering to that. I meant that you shouldn't do OGR_FD_Release( hFDefnIn ) on a field definition returned by OGR_L_GetLayerDefn(), otherwise you'll get into memory corruption issues.
Le samedi 04 septembre 2010 05:17:38, Stephen Woodbridge a écrit : > Thank you, still learning my way around things. > > So after copying 90% of the my not working source code into the test > program and it worked there, it finally dawned on me to check the > Makefile. Duh! while I had removed all the shapelib calls from the > source code, I forgot to check the link line to remove adding -lshp > which apparently was causing the bogus behavior. Cleaned that up and > things started working as expected. > > Thanks for all the help guys. It is very much appreciated. > > -Steve > > On 9/3/2010 2:20 PM, Even Rouault wrote: > > 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 :( > >> > >> wood...@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 > > _______________________________________________ > gdal-dev mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/gdal-dev _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
