Bug report #957

QGIS crashes when trying to export shapefile from Postgis where record has NULL geometry

Added by Andreas Neumann almost 17 years ago. Updated over 15 years ago.

Status:Closed
Priority:Low
Assignee:nobody -
Category:Build/Install
Affected QGIS version: Regression?:No
Operating System:Debian Easy fix?:No
Pull Request or Patch supplied: Resolution:fixed
Crashes QGIS or corrupts data: Copied to github as #:11016

Description

When exporting data from Postgis to a shapefile and one or more records have a NULL geometry it seems like QGIS crashes during the export. Attached is a sample SQL file where one record (the one with gid=450) has a NULL geometry.

To reproduce, create an empty Postgis database and a schema called "natur". Then import the file attached to this bug with "psql -U an -d yourdb -f oekoflaech.sql" --> add the file to QGIS --> right click on the layer and --> Save as shapefile --> QGIS crashes.

This is consistent on both Linux and Windows with a fairly recent SVN version.

oekoflaech.sql.gz - A sample Postgis SQL file where one row has a null geometry (60.5 KB) Andreas Neumann, 2008-02-21 09:23 AM

History

#1 Updated by Frank Warmerdam - almost 17 years ago

I don't have a postgis instance readily available, so I tried to reproduce this by opening a new vector layer from a .csv file (no geometries) and then doing "save to shapefile" from the layer entry in the layer list. This seemed to work ok though no actual records were written - presumably because none of them had geometry.

This leads me to wonder if the problem is specific to postgis or if I'm just approaching it wrong.

#2 Updated by Frank Warmerdam - almost 17 years ago

racicot reports this traceback:

Program received signal SIGABRT, Aborted.
[Switching to Thread -1259669824 (LWP 19480)]
0xffffe410 in +kernel_vsyscall ()
(gdb) bt
#0  0xffffe410 in +kernel_vsyscall ()
#3905  0xb6271875 in raise () from /lib/tls/i686/cmov/libc.so.6
#3906  0xb6273201 in abort () from /lib/tls/i686/cmov/libc.so.6
#3907  0xb626ab6e in +assert_fail () from /lib/tls/i686/cmov/libc.so.6
#3908  0xb6ed0715 in [[QgsVectorFileWriter]]::createEmptyGeometry (this=0x88fdd68, wkbType=QGis::WKBUnknown)
    at /usr/local/src/qgis/qgis_svn/src/core/qgsvectorfilewriter.cpp:176
#3909  0xb6ed0d86 in [[QgsVectorFileWriter]]::addFeature (this=0x88fdd68, feature=@0xbfbea084)
    at /usr/local/src/qgis/qgis_svn/src/core/qgsvectorfilewriter.cpp:244
#3910  0xb6ed208e in [[QgsVectorFileWriter]]::writeAsShapefile (layer=0x8896e88, shapefileName=@0xbfbea12c, fileEncoding=@0xbfbea130,
    onlySelected=false) at /usr/local/src/qgis/qgis_svn/src/core/qgsvectorfilewriter.cpp:329
#3911  0x0828368c in [[QgsLegendLayerFile]]::saveAsShapefileGeneral (this=0x88b0180, saveOnlySelection=false)
    at /usr/local/src/qgis/qgis_svn/src/app/legend/qgslegendlayerfile.cpp:387

#3 Updated by Frank Warmerdam - almost 17 years ago

So, the problem is triggered by passing something unexpected (like wkbNone or equivelent?) into createEmptyGeometry(). This method is substantially restructured in the gdalogr-capi branch and I'm not sure the problem will still exist there.

If that will be merged soon, I would suggest holding this ticket till after that merge.

#4 Updated by Jürgen Fischer over 16 years ago

  • Resolution set to fixed
  • Status changed from Open to Closed

looks like the C-API handles this more gracefully.
probably fixed since fb8424db (SVN r8223), verified in 317ec563 (SVN r8292).

#5 Updated by Anonymous over 15 years ago

Milestone Version 0.9.2 deleted

Also available in: Atom PDF