Bug report #16198

QgsGeometry().asPolygon() segfaults, Python, SIP

Added by Christoph Fink almost 8 years ago. Updated over 6 years ago.

Status:Closed
Priority:High
Assignee:-
Category:Python plugins
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:Yes Copied to github as #:24108

Description

calling the asPolygon() member function of any QgsGeometry in Python (on the console and from within a plugin) produces a segmentation fault

To reproduce it, run the following two lines on the python console:

geometry = QgsGeometry().fromWkt("Polygon((0 0,10 0,10 10,0 10, 0 0))")
polygon = geometry.asPolygon()

I am running Python 3.6 and PyQt 5.7.1
The backtrace is from a CMAKE_BUILD_TYPE=Release binary, I am in the middle of compiling a Debug binary

backtrace - backtrace (5.99 KB) Christoph Fink, 2017-02-15 05:43 PM

qgis-20170219-131239-760-3776-3496871.zip (3.39 MB) Christoph Fink, 2017-02-19 04:10 AM

sysinfo.txt Magnifier - Windows systeminfo.exe output (2.32 KB) Christoph Fink, 2017-02-19 04:13 AM

History

#1 Updated by Nyall Dawson almost 8 years ago

No crash here (python 3.6/qt 5.7.1). Likely a local build or library issue...

#2 Updated by Christoph Fink almost 8 years ago

  • Status changed from Open to Closed

Indeed, I cannot reproduce it any more in any other enviroment than Arch with qgis-git from AUR.
I’ll try to figure out which dependency is the culprit and file it as a bug with the AUR-package maintainer.

#3 Updated by Christoph Fink almost 8 years ago

  • Status changed from Closed to Reopened

Reopening because it seems to affect the osgeo4w qgis-dev build, too, in case of MultiPolygons:

wkt = 'MultiPolygon (((0 0,10 0,10 10,0 10, 0 0)))'
geometry = QgsGeometry().fromWkt(wkt)
print(repr(geometry.isMultipart()))
multiPolygon = geometry.asMultiPolygon()

minidump attached, no idea how to debug it on Windows

#5 Updated by Christoph Fink almost 8 years ago

#6 Updated by Giovanni Manghi over 7 years ago

  • OS version deleted (up-to-date as of 2016-02-16, 24)
  • Operating System deleted (Arch, Fedora)
  • Target version set to Version 3.0
  • Priority changed from Normal to High
  • Description updated (diff)

Christoph Fink wrote:

Reopening because it seems to affect the osgeo4w qgis-dev build, too, in case of MultiPolygons:

confirmed on master/qgis3.

#7 Updated by Giovanni Manghi over 7 years ago

  • Regression? set to No
  • Easy fix? set to No

#8 Updated by Matthias Kuhn over 7 years ago

No crash here (QGIS 2.99 / QGIS 2.18) with multipolygon (Linux, Fedora 25)

#9 Updated by Giovanni Manghi over 7 years ago

  • Status changed from Reopened to Feedback

#10 Updated by Wei Ji Leong over 7 years ago

Giovanni Manghi wrote:

Christoph Fink wrote:

Reopening because it seems to affect the osgeo4w qgis-dev build, too, in case of MultiPolygons:

confirmed on master/qgis3.

Crashes on Windows (Python 3.6.0, Qt 5.7.1) osgeo4w installed qgis-dev build e505ebc. Appears to be only limited to Polygons and Multipolygons. E.g. QgsGeometry().fromWkt("LineString(0 0,10 0,10 10,0 10, 0 0)").asPolyline() works without crashing.

Temp hacky workaround:
geometry = QgsGeometry().fromWkt("Polygon((0 0,10 0,10 10,0 10, 0 0))")
geometry.asPolygon() #crashes
[(node.x(), node.y()) for node in geometry.asQPolygonF()] #works

#11 Updated by Giovanni Manghi over 6 years ago

No crash anymore on latest QGIS 3 on Windows. Please leave feedback.

#12 Updated by Christoph Fink over 6 years ago

No crash on QGIS Master (git commit 345088c863) on Linux (Qt 5.10, Python 3.6.4) either. Thank you!

#13 Updated by Giovanni Manghi over 6 years ago

  • Status changed from Feedback to Closed
  • Resolution set to fixed/implemented

Also available in: Atom PDF