Bug report #13535

Crash using Geometry Checker plugin

Added by Salvatore Larosa about 9 years ago. Updated over 8 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:Sandro Mani
Category:C++ plugins/Geometry Checker
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 #:21577

Description

Performing a check on a Polygon layer (attached) I am getting the following stacktrace:

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7fff6b54d700 (LWP 1838)]
0x00007fffee99b165 in raise () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
#0  0x00007fffee99b165 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007fffee99e3e0 in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007fffee9d539b in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#3  0x00007fffee9debe6 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#4  0x00007fffee9e398c in free () from /lib/x86_64-linux-gnu/libc.so.6
#5  0x00007ffff41465ca in QgsGeos::~QgsGeos (this=0x7fff74114840, __in_chrg=<optimized out>)
    at /home/sam/pacchetti_gis/QGIS/src/core/geometry/qgsgeos.cpp:137
#6  0x00007fffd415d310 in QgsGeometryDuplicateCheck::collectErrors (this=0x40280c0, errors=..., messages=..., progressCounter=0x3eb3f4c, ids=...)
    at /home/sam/pacchetti_gis/QGIS/src/plugins/geometry_checker/checks/qgsgeometryduplicatecheck.cpp:58
#7  0x00007fffd414cd73 in QgsGeometryChecker::runCheck (this=0x3eb3f10, check=0x40280c0)
    at /home/sam/pacchetti_gis/QGIS/src/plugins/geometry_checker/qgsgeometrychecker.cpp:243
#8  0x00007fffd414d67c in QgsGeometryChecker::RunCheckWrapper::operator() (this=0x3f31058, check=0x40280c0)
    at /home/sam/pacchetti_gis/QGIS/src/plugins/geometry_checker/qgsgeometrychecker.h:57
#9  0x00007fffd4151cd3 in QtConcurrent::MapKernel<QList<QgsGeometryCheck*>::iterator, QgsGeometryChecker::RunCheckWrapper>::runIteration (this=
    0x3f31020, it=...) at /usr/include/qt4/QtCore/qtconcurrentmapkernel.h:73
#10 0x00007fffd4151d57 in QtConcurrent::MapKernel<QList<QgsGeometryCheck*>::iterator, QgsGeometryChecker::RunCheckWrapper>::runIterations (this=
    0x3f31020, sequenceBeginIterator=..., beginIndex=2, endIndex=3) at /usr/include/qt4/QtCore/qtconcurrentmapkernel.h:82
#11 0x00007fffd4152205 in QtConcurrent::IterateKernel<QList<QgsGeometryCheck*>::iterator, void>::forThreadFunction (this=0x3f31020)
    at /usr/include/qt4/QtCore/qtconcurrentiteratekernel.h:263
#12 0x00007fffd4151ee8 in QtConcurrent::IterateKernel<QList<QgsGeometryCheck*>::iterator, void>::threadFunction (this=0x3f31020)
    at /usr/include/qt4/QtCore/qtconcurrentiteratekernel.h:225
#13 0x00007ffff1fc1b85 in QtConcurrent::ThreadEngineBase::run() () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#14 0x00007ffff1fc36bd in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#15 0x00007ffff1fcfd0b in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#16 0x00007fffee753b50 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#17 0x00007fffeea4495d in clone () from /lib/x86_64-linux-gnu/libc.so.6
#18 0x0000000000000000 in ?? ()

shape.zip (262 KB) Salvatore Larosa, 2015-10-06 01:58 PM

gc.mp4 (2.39 MB) Giovanni Manghi, 2015-10-10 01:09 AM

test_gc.dbf.zip (1.24 KB) Giovanni Manghi, 2015-10-10 01:09 AM

win7.png (101 KB) R. R., 2016-02-03 08:26 AM

ubuntu_14_04__1.png (125 KB) R. R., 2016-02-03 08:26 AM

ubuntu_14_04__2.png (189 KB) R. R., 2016-02-03 08:26 AM

stacktrace_qgis_2_14_ubuntu_14_04 (23.1 KB) R. R., 2016-03-05 04:34 AM

geometry_checker_crash.zip (654 KB) R. R., 2016-03-05 11:37 AM

qgis-2.14.0_git20160309_107d30a_20trusty.zip (228 KB) R. R., 2016-03-12 10:28 AM

qgis-2.14.0_git20160319_08a1b07_20trusty.zip (490 KB) R. R., 2016-03-24 10:14 AM

gap_check_topology_exception.png (16.7 KB) R. R., 2016-07-07 01:10 AM

post_no36.png (52.1 KB) R. R., 2016-07-07 03:25 AM

History

#1 Updated by Salvatore Larosa about 9 years ago

Sandro Mani seems not to be into the "assigned to" list. How can I notify this to him?

#2 Updated by Giovanni Manghi about 9 years ago

  • Assignee set to Sandro Mani
  • Target version set to Future Release - High Priority

#3 Updated by Giovanni Manghi about 9 years ago

These days I can only test master on Windows and I confirm the crash when trying to fix a simple polygon with 1 self-intersection when choosing "split feature into multi object feature".

On the other end if choosing "split feature in multiple single-object features" do no causes crash, but one of the two (supposedly) output polygons is lost.

#4 Updated by Giovanni Manghi about 9 years ago

Salvatore Larosa wrote:

Sandro Mani seems not to be into the "assigned to" list. How can I notify this to him?

I have added to the list... but then it depends if he configured his account to receive notifications from tickets, so maybe is better to notify him directly too.

#5 Updated by Sandro Mani about 9 years ago

I got the notifications. Thanks for reporting the issues, I'll look into them.

#6 Updated by Sandro Mani about 9 years ago

@Giovanni Manghi: I see a crash when I zoom on the canvas after the self-intersection fix is complete (i.e. when fix summary dialog is shown). This appears to be caused by corruption in the wkb string of the geometry, even though it looks correct as it is returned by QgsGeometryCollectionV2::asWkb - the corruption appears to happen later on in QgsMapToPixelSimplifier::simplifyWkbGeometry. Can you confirm that this is the same issue you are seeing?

Salvatore Larosa: Could you please specify which checks are active when you trigger the crash?

#7 Updated by Sandro Mani about 9 years ago

So the actual cause of the post-self-intersection fix crash I described above is that QgsMapToPixelSimplifier does not handle curved geometries correctly. Curved geometries arose because the self-intersection fix created new parts as CurvePolygons. I've changed this [1] and now if the original feature was a linear polygon, then the new part will also be one. This prevents the crash from happening when fixing linear polygons, but the issue with QgsMapToPixelSimplifier remains.

[1] https://github.com/manisandro/QGIS/commit/af983331776fb880c56dba3ffc1e6a6eceaf3cd8

#8 Updated by Salvatore Larosa about 9 years ago

Sandro Mani wrote:

Salvatore Larosa: Could you please specify which checks are active when you trigger the crash?

Geometry validity:
Self intersection, Duplicate nodes ad Polygon with less 3 nodes.

Topology checks:
Check for duplicates, Check for features within other features

#9 Updated by Giovanni Manghi about 9 years ago

Sandro Mani wrote:

@Giovanni Manghi: I see a crash when I zoom on the canvas after the self-intersection fix is complete (i.e. when fix summary dialog is shown). This appears to be caused by corruption in the wkb string of the geometry, even though it looks correct as it is returned by QgsGeometryCollectionV2::asWkb - the corruption appears to happen later on in QgsMapToPixelSimplifier::simplifyWkbGeometry. Can you confirm that this is the same issue you are seeing?

Salvatore Larosa: Could you please specify which checks are active when you trigger the crash?

Screencast and sample data attached. Cheers!

#10 Updated by Sandro Mani about 9 years ago

Could you please re-test against the latest master? It contains some Geometry Checker fixes as well as changes at QgsGeos level.

#11 Updated by Nyall Dawson about 9 years ago

  • Status changed from Open to Feedback

#12 Updated by Salvatore Larosa about 9 years ago

Works fine for me in current master. I leave the ticket opened for more feedback from Giovanni.

#13 Updated by Giovanni Manghi about 9 years ago

  • Status changed from Feedback to Closed

Also fine here. Thanks!

#14 Updated by Giovanni Manghi about 9 years ago

  • Resolution set to fixed/implemented

#15 Updated by R. R. almost 9 years ago

On Windows 7 the 'Check Geometries' plugin may cause a crash when 'Topology checks' are activated. I've tested the .shp file uploaded by Salvatore Larosa and 'Check for duplicates' isn't working (see attachment). On Ubuntu 14.04 there is no crash but QGIS says 'Check error occurred' in a separate dialogue window.

QGIS 2.12.3

#16 Updated by Sandro Mani almost 9 years ago

The crash under windows needs to be investigated.

The dialog shown about check errors is expected: The layer contains issues which are preventing the duplicate check from working (specifically, because the geometry engine, GEOS, won't handle geometries with self intersections, and GEOS is being used to check for topology issues). So you'll need to fix those errors first, and then do the topology checks once those errors are fixed.

#17 Updated by Jürgen Fischer almost 9 years ago

Reinhard Reiterer wrote:

On Windows 7 the 'Check Geometries' plugin may cause a crash when 'Topology checks' are activated. I've tested the .shp file uploaded by Salvatore Larosa and 'Check for duplicates' isn't working (see attachment). On Ubuntu 14.04 there is no crash but QGIS says 'Check error occurred' in a separate dialogue window.

Doesn't crash here on windows with master.

#18 Updated by R. R. over 8 years ago

I did some testing and the "Geometry checker" often crashes when dealing with complex features. Seems it's a cross-platform issue. I've uploaded the stacktrace of a Ubuntu crash report.

#19 Updated by Sandro Mani over 8 years ago

If possible, please provide a dataset with which to reproduce and specify how you set up the geometry checker.

#20 Updated by R. R. over 8 years ago

Hope this helps.

@ #16
Thanks for the detailed explanation.

#21 Updated by Sandro Mani over 8 years ago

Thanks, can reproduce, will analyze.

#23 Updated by R. R. over 8 years ago

The fix seems to work. Unfortunately the 'Check geometries' plugin is still facing issues. I've uploaded the .shp files.

#25 Updated by Nyall Dawson over 8 years ago

  • Status changed from Reopened to Closed

PR merged, should be fixed in master and 2.14 now.

#26 Updated by R. R. over 8 years ago

Is the fix #2905 already implemented? QGIS (1:2.14.0+git20160315+342a754+20trusty) is still crashing.

#27 Updated by R. R. over 8 years ago

I've tested the 'Check Geometries' plugin on several layers and everything seems to work now :)

#28 Updated by R. R. over 8 years ago

Hi Sandro, I've noticed another bug. When trying to fix the selected errors QGIS crashes again (see attachment).

#29 Updated by Sandro Mani over 8 years ago

Wow, that was a nasty bug. Could you try the branch https://github.com/manisandro/QGIS/tree/geom_checker_fixes (last two commits are the relevant ones)? Thanks

#30 Updated by Sandro Mani over 8 years ago

Oh and you'll need to reduce the precision to 1E-6 for the test case you attached. Reason are GEOS precision issues.

#31 Updated by R. R. over 8 years ago

Is there any way to implement the fix in the next master? I don't know how to install a branch.

#32 Updated by Sandro Mani over 8 years ago

Now merged in master

#33 Updated by R. R. over 8 years ago

  • Status changed from Reopened to Closed

Thanks for your help, the 'Geometry Checker' is no longer crashing. However, fixing minimum area issues may be quite tricky if there are no neighboring polygons to merge with.

#34 Updated by R. R. over 8 years ago

Is there anything I can do when the gap check reports a topology exception (see gap_check_topology_exception.png)? Is this a bug?

#35 Updated by Sandro Mani over 8 years ago

It is unlikely a bug (in the QGIS code at least). Can you spot a faulty geometry at the position indicated?

#36 Updated by R. R. over 8 years ago

The layer includes many sliver polygons, that the geometry checker can't fix. Maybe I'm doing something wrong?

#37 Updated by Sandro Mani over 8 years ago

Please open a separate issue and attach the problematic data.

#38 Updated by R. R. over 8 years ago

I can not attach the data as the shape files are proprietary :/

Also available in: Atom PDF