Segmentation fault when clipping Polyhedra
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
Clipping an unstructured grid containing more than one polyhedron (cell type 42) in Paraview 3.10.1 64-bit and 3.12.0-RC2 64-bit yields a segmentation fault. A minimal example containing two tetrahedra is attached as .vtu file. Plane-clipping the grid with a Z-Normal should reproduce the seg. fault.
The crash could also be reproduced with ParaView git/master as follows:
- Load file
- Filters - Clip Clip Type: Plane Origin: 0.3, 0.5, 0.5 Normal: 1, 0, 0 Tick "Inside Out" checkbox Apply (One may need to toggle the checkbox a couple of times and pressing Apply each time after toggling until the segfault gets triggered.)
=> 0x00007fffdf00166a in vtkDataSetSurfaceFilter::InsertPolygonInHash (this=0x2a09270, ids=0x2bd7cb0, numPts=0, sourceId=0) at /opt/ParaView3.git/VTK/Graphics/vtkDataSetSurfaceFilter.cxx:1797 1797 quad = end; (gdb) list 1794 1789 vtkIdType tab = new vtkIdType[numPts]; 1790 for(int i=0; i<numPts; i++) 1791 { 1792 tab[i] = ids[(offset+i)%numPts]; 1793 } 1794 1795 // Look for existing hex in the hash; 1796 end = this->QuadHash + tab[0]; 1797 quad = *end; (gdb) print numPts $1 = 0 (gdb) print tab[0] $1 = -614752568
The segfault is triggered by the variable 'numPts' being zero which causes the for-loop in line 1790 being skipped such that the array 'tab' is not initialized, but still queried at position 0 in line 1796. So, 'end' points to some random location in memory and dereferencing it in line 1797 causes the segfault.