Bug report #15507

QGIS crashes with GEOS Exception: IllegalArgumentException: Invalid number of points in LinearRing found 3 - must be 0 or >= 4

Added by Tudor Bărăscu about 3 years ago. Updated over 2 years ago.

Status:Closed
Priority:High
Assignee:Sandro Santilli
Category:Projection Support
Affected QGIS version:2.18.7 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:Yes Resolution:fixed/implemented
Crashes QGIS or corrupts data:Yes Copied to github as #:23431

Description

The problem has also been encountered in the mailing list https://lists.osgeo.org/pipermail/qgis-developer/2016-May/042692.html

QGIS simply crashes in some projects that have specific geometry although I tested the geometry validity and it's all good.

The error is:

src/core/qgsmessagelog.cpp: 45: (logMessage) [0ms] [thread:0x605ec20] 2016-08-31T21:44:39 GEOS[1] Exception: IllegalArgumentException: Invalid number of points in LinearRing found 3 - must be 0 or >= 4
src/core/geometry/qgsgeos.cpp: 63: (throwGEOSException) [0ms] [thread:0x605ec20] GEOS exception: IllegalArgumentException: RobustDeterminant encountered non-finite numbers

The problem was tested under Spatialite and under Postgis.
I've turned feature simplification off in QGIS to no avail.
I've attached data and you can replicate by taking the following steps:

- Open the project
- Change the CRS from 4326 to 3857 (web mercator)
- Crash

Depending on the styling/labeling, it may not crash.

I can replicate under QGIS 2.14.6 and 2.16.2

Thanks

bug_geos.zip (207 KB) Tudor Bărăscu, 2016-08-31 12:37 PM

Associated revisions

Revision 126cf5f1
Added by Sandro Santilli over 2 years ago

Check return from QgsPalLabeling::prepareGeometry before dereference

Fixes #15507

Includes automated test.

History

#1 Updated by Jukka Rahkonen about 3 years ago

Source data contains vertices like POINT (25.714286 -90)which are outside the valid area for EPSG:3857 which is "World between 85.06°S and 85.06°N." http://epsg.io/3857. I guess that latitude -90 leads to divide by zero error and it just can't work.

Crash is not the best thing to happen but how to prevent it and throw an error instead?

#2 Updated by Giovanni Manghi over 2 years ago

  • Category set to Projection Support
  • Priority changed from Normal to High
  • Target version set to Version 2.18
  • Affected QGIS version changed from 2.14.5 to 2.18.4
  • Crashes QGIS or corrupts data changed from No to Yes
  • Operating System deleted (Debian Stretch)

#3 Updated by Giovanni Manghi over 2 years ago

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

#4 Updated by Sandro Santilli over 2 years ago

  • Status changed from Open to In Progress
  • Assignee set to Sandro Santilli
  • Description updated (diff)

#5 Updated by Sandro Santilli over 2 years ago

  • Affected QGIS version changed from 2.18.4 to 2.18.7

Can still be reproduced as of fd7b52d5b8e668bd5db43f81eecc60818ff490ab (current release-2_18 branch)

#6 Updated by Sandro Santilli over 2 years ago

  • Pull Request or Patch supplied changed from No to Yes

#7 Updated by Sandro Santilli over 2 years ago

NOTE: the pull request referenced above is for the 2.18 release.

I've tried to reproduce this bug on master branch and obtained a different behavior: no crash but nothing rendered (while the patch to 2.18 branch also gives a working rendering)

#8 Updated by Sandro Santilli over 2 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

#9 Updated by Sandro Santilli over 2 years ago

  • Status changed from Closed to Reopened

I'm reopening to get this also fixed in the master branch, where the crash is not present but the features disappear from the map completely instead, logging the "IllegalArgumentException: Invalid number of points in LinearRing found" message.

#10 Updated by Sandro Santilli over 2 years ago

4ed096b94dff3101786e67a49567544f77c759d8 forward-ports the test to master (but no fix was needed there to avoid the crash)

#11 Updated by Sandro Santilli over 2 years ago

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

Actually, as the crash is fixed, I'm closing this again.
It's better to have a separate issue for the lack of GUI error message (is an enhancement)
and for the rendering issue (it's not a crash).

Also available in: Atom PDF