Bug #5239

TIN interpolation causes crash

Added by Giovanni Manghi about 1 year ago. Updated 5 months ago.

Status:Feedback Start Date:03/26/2012
Priority:High Due date:
Assigned to:Marco Hugentobler % Done:

0%

Category:C++ Plugins
Target version:Version 2.0.0
Platform: Patch supplied:Yes
Platform version: Affected version:master
Status info: Causes crash or corruption:Yes
Resolution:

Description

Tested on master and 1.7.4 on both linux and windows.

The attached layer "3763" causes qgis to crash if interpolating (with the "Z" column) with the "interpolation" plugin and the TIN method. Works fine with IDW.

Strangely enough, the very same layer saved in another CRS (attached here) does not cause the tool to crash qgis.

In both cases the project CRS was set as the same as the layer being processed.

MoBatimIST_shp.zip (104.3 kB) Giovanni Manghi, 03/26/2012 03:48 pm

3763_shp.zip (156.2 kB) Giovanni Manghi, 03/26/2012 03:48 pm

DualEdgeTriangulation.h.diff (1.5 kB) Thomas Arnold, 03/30/2012 01:49 pm

DualEdgeTriangulation.cc.diff (346 Bytes) Thomas Arnold, 03/30/2012 01:49 pm

test2.xyz (2.7 MB) Tristan Allouis, 05/25/2012 01:37 am

0001-5239_v1.patch (6.5 kB) Thomas Arnold, 06/01/2012 12:15 am


Related issues

duplicates Quantum GIS Desktop - Bug #2482: Interpolation plugin causes seg fault Closed 07/25/2011

History

Updated by Thomas Arnold about 1 year ago

Hi,

could anybody check this solution?
I think it was a numerical problem. The value of the leftOfTresh was too small. So the case "p is in a line with p0 and p1" could not detect.

Thomas

Updated by Giovanni Manghi about 1 year ago

  • Patch supplied changed from No to Yes

Updated by Giovanni Manghi about 1 year ago

  • Target version changed from 35 to Version 1.8.0

Updated by Giovanni Manghi about 1 year ago

probably duplicate of #2482

Updated by Tristan Allouis 12 months ago

Same problem: Segmentation fault using the "interpolation" plugin and the TIN method on a xyz dataset (Z interpolation).
I checked the patch but it bit not fix the problem.

According to my tests, qgis crashes when the points to interpolate are too close (too dense dataset).
I enclose a dataset that causing qgis to crash. Use the SCR ID 10090.

Please can you test this dataset and report if it crashes or not ?

Thanks!

Updated by Salvatore Larosa 12 months ago

Reverting the patch does not work! (tested w/test2.xyz)

below the backtrace, if it can you help:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff4220c79 in MathUtils::triArea(Point3D*, Point3D*, Point3D*) ()
   from /usr/local/lib/libqgis_analysis.so.1.8.0
(gdb) bt
#0  0x00007ffff4220c79 in MathUtils::triArea(Point3D*, Point3D*, Point3D*) ()
   from /usr/local/lib/libqgis_analysis.so.1.8.0
#1  0x00007ffff421f74a in MathUtils::inCircle(Point3D*, Point3D*, Point3D*, Point3D*) ()
   from /usr/local/lib/libqgis_analysis.so.1.8.0
#2  0x00007ffff420a1ef in DualEdgeTriangulation::checkSwap(unsigned int) ()
   from /usr/local/lib/libqgis_analysis.so.1.8.0
#3  0x00007ffff420a768 in DualEdgeTriangulation::doSwap(unsigned int) ()
   from /usr/local/lib/libqgis_analysis.so.1.8.0
#4  0x00007ffff420a204 in DualEdgeTriangulation::checkSwap(unsigned int) ()
   from /usr/local/lib/libqgis_analysis.so.1.8.0
#5  0x00007ffff420a768 in DualEdgeTriangulation::doSwap(unsigned int) ()
   from /usr/local/lib/libqgis_analysis.so.1.8.0
#6  0x00007ffff420a204 in DualEdgeTriangulation::checkSwap(unsigned int) ()
   from /usr/local/lib/libqgis_analysis.so.1.8.0
#7  0x00007ffff420a768 in DualEdgeTriangulation::doSwap(unsigned int) ()
   from /usr/local/lib/libqgis_analysis.so.1.8.0
#8  0x00007ffff420a204 in DualEdgeTriangulation::checkSwap(unsigned int) ()
   from /usr/local/lib/libqgis_analysis.so.1.8.0
#9  0x00007ffff420a768 in DualEdgeTriangulation::doSwap(unsigned int) ()
   from /usr/local/lib/libqgis_analysis.so.1.8.0
#10 0x00007ffff420a204 in DualEdgeTriangulation::checkSwap(unsigned int) ()
   from /usr/local/lib/libqgis_analysis.so.1.8.0
#11 0x00007ffff420a768 in DualEdgeTriangulation::doSwap(unsigned int) ()
........................

loop till to the end, alterning doSwap and checkSwap!

Updated by Giovanni Manghi 12 months ago

  • Status changed from New to Closed

merging this with #5239

Updated by Giovanni Manghi 12 months ago

Giovanni Manghi wrote:

merging this with #5239

see also #2482

Updated by Giovanni Manghi 12 months ago

  • Status changed from Closed to Reopened

Updated by Thomas Arnold 12 months ago

Hi,

the mean problem is the recursiv call checkSwap<->doSwap. I don't know the precise reason why the recursion sometimes never ends. But how about the simple strategy to limit the recrusiv deep? I know that is not ideal. But this prevent that qgis crashes.

Thomas

By the way I used the "git format-patch" command to create this patch. I hope it is ok.

Updated by Tristan Allouis 12 months ago

Hello,
Thank you for the patch Thomas, it works well !

Updated by Marco Hugentobler 12 months ago

I agree the numerical stability of the triangulation code is not rock-solid (and if there are volunteers for maintaining the triangulation code, that would be great).

As Thomas points out, limiting the recursive depth of the swaping is not optimal (in extreme cases, one point insertion could swap all the existing edges in a triangulation). Therefore, I'm not applying that patch to the git repo.

Updated by Paolo Cavallini 9 months ago

  • Target version changed from Version 1.8.0 to Version 2.0.0

Updated by Giovanni Manghi 8 months ago

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

Tested again on master and it works fine, no more crashes.

Updated by Salvatore Larosa 6 months ago

  • Status changed from Closed to Reopened
  • Resolution deleted (fixed)

Still persists ! (at least under Linux)

Updated by Giovanni Manghi 5 months ago

  • Status changed from Reopened to Feedback

Salvatore Larosa wrote:

Still persists ! (at least under Linux)

tested now on linux (ubuntu) and qgis master and seems to work ok. Salvatore, still a crash for you?

Updated by Salvatore Larosa 5 months ago

Giovanni Manghi wrote:

tested now on linux (ubuntu) and qgis master and seems to work ok. Salvatore, still a crash for you?

Hi Giovanni,
yes, it still happens here with a similar backtrace (as above):

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff3fb29a0 in MathUtils::triArea (pa=0x60f94a0, pb=0x6455cc0, pc=0x63f7a00)
    at /home/sam/pacchetti_gis/Quantum-GIS/src/analysis/interpolation/MathUtils.cc:503
503        double deter = ( pa->getX() * pb->getY() + pb->getX() * pc->getY() + pc->getX() * pa->getY() - pa->getX() * pc->getY() - pb->getX() * pa->getY() - pc->getX() * pb->getY() );
(gdb) bt
#0  0x00007ffff3fb29a0 in MathUtils::triArea (pa=0x60f94a0, pb=0x6455cc0, pc=0x63f7a00)
    at /home/sam/pacchetti_gis/Quantum-GIS/src/analysis/interpolation/MathUtils.cc:503
#1  0x00007ffff3fb07ff in MathUtils::inCircle (testp=0x63f7a00, p1=0x6454620, p2=0x60f94a0, p3=
    0x6455cc0) at /home/sam/pacchetti_gis/Quantum-GIS/src/analysis/interpolation/MathUtils.cc:266
#2  0x00007ffff3f95aab in DualEdgeTriangulation::checkSwap (this=0x645fa00, edge=359)
    at /home/sam/pacchetti_gis/Quantum-GIS/src/analysis/interpolation/DualEdgeTriangulation.cc:692
#3  0x00007ffff3f96024 in DualEdgeTriangulation::doSwap (this=0x645fa00, edge=909)
    at /home/sam/pacchetti_gis/Quantum-GIS/src/analysis/interpolation/DualEdgeTriangulation.cc:735
#4  0x00007ffff3f95ac0 in DualEdgeTriangulation::checkSwap (this=0x645fa00, edge=909)
    at /home/sam/pacchetti_gis/Quantum-GIS/src/analysis/interpolation/DualEdgeTriangulation.cc:694
#5  0x00007ffff3f96024 in DualEdgeTriangulation::doSwap (this=0x645fa00, edge=483)
    at /home/sam/pacchetti_gis/Quantum-GIS/src/analysis/interpolation/DualEdgeTriangulation.cc:735
#6  0x00007ffff3f95ac0 in DualEdgeTriangulation::checkSwap (this=0x645fa00, edge=483)
    at /home/sam/pacchetti_gis/Quantum-GIS/src/analysis/interpolation/DualEdgeTriangulation.cc:694
#7  0x00007ffff3f96024 in DualEdgeTriangulation::doSwap (this=0x645fa00, edge=689)
    at /home/sam/pacchetti_gis/Quantum-GIS/src/analysis/interpolation/DualEdgeTriangulation.cc:735
#8  0x00007ffff3f95ac0 in DualEdgeTriangulation::checkSwap (this=0x645fa00, edge=689)
    at /home/sam/pacchetti_gis/Quantum-GIS/src/analysis/interpolation/DualEdgeTriangulation.cc:694
#9  0x00007ffff3f96024 in DualEdgeTriangulation::doSwap (this=0x645fa00, edge=359)
    at /home/sam/pacchetti_gis/Quantum-GIS/src/analysis/interpolation/DualEdgeTriangulation.cc:735
#10 0x00007ffff3f95ac0 in DualEdgeTriangulation::checkSwap (this=0x645fa00, edge=359)
    at /home/sam/pacchetti_gis/Quantum-GIS/src/analysis/interpolation/DualEdgeTriangulation.cc:694
#11 0x00007ffff3f96024 in DualEdgeTriangulation::doSwap (this=0x645fa00, edge=909)

Tested with the attached dataset (3763.shp)

Also available in: Atom PDF