vtkPLYReader crashes for some files due to infinite loop in vtkIncrementalOctreeNode
When loading certain PLY files that contain texture coordinates (such as this example PLY file, exported by MeshLab) then the application crashes with stack overflow.
Stack (most recently called on top):
...this same line is repeated hundreds of times
vtkCommon-9.1d.dll!vtkIncrementalOctreeNode::CreateChildNodes(vtkPoints * points, vtkIdList * pntIds, const double * newPnt, __int64 * pntIdx, int maxPts, int ptMode, int & numberOfNodes) Line 426 C++
vtkCommon-9.1d.dll!vtkIncrementalOctreeNode::CreateChildNodes(vtkPoints * points, vtkIdList * pntIds, const double * newPnt, __int64 * pntIdx, int maxPts, int ptMode, int & numberOfNodes) Line 426 C++
vtkCommon-9.1d.dll!vtkIncrementalOctreeNode::CreateChildNodes(vtkPoints * points, vtkIdList * pntIds, const double * newPnt, __int64 * pntIdx, int maxPts, int ptMode, int & numberOfNodes) Line 426 C++
vtkCommon-9.1d.dll!vtkIncrementalOctreeNode::CreateChildNodes(vtkPoints * points, vtkIdList * pntIds, const double * newPnt, __int64 * pntIdx, int maxPts, int ptMode, int & numberOfNodes) Line 426 C++
vtkCommon-9.1d.dll!vtkIncrementalOctreeNode::CreateChildNodes(vtkPoints * points, vtkIdList * pntIds, const double * newPnt, __int64 * pntIdx, int maxPts, int ptMode, int & numberOfNodes) Line 426 C++
vtkCommon-9.1d.dll!vtkIncrementalOctreeNode::CreateChildNodes(vtkPoints * points, vtkIdList * pntIds, const double * newPnt, __int64 * pntIdx, int maxPts, int ptMode, int & numberOfNodes) Line 426 C++
vtkCommon-9.1d.dll!vtkIncrementalOctreeNode::CreateChildNodes(vtkPoints * points, vtkIdList * pntIds, const double * newPnt, __int64 * pntIdx, int maxPts, int ptMode, int & numberOfNodes) Line 426 C++
vtkCommon-9.1d.dll!vtkIncrementalOctreeNode::CreateChildNodes(vtkPoints * points, vtkIdList * pntIds, const double * newPnt, __int64 * pntIdx, int maxPts, int ptMode, int & numberOfNodes) Line 426 C++
vtkCommon-9.1d.dll!vtkIncrementalOctreeNode::CreateChildNodes(vtkPoints * points, vtkIdList * pntIds, const double * newPnt, __int64 * pntIdx, int maxPts, int ptMode, int & numberOfNodes) Line 426 C++
vtkCommon-9.1d.dll!vtkIncrementalOctreeNode::InsertPoint(vtkPoints * points, const double * newPnt, int maxPts, __int64 * pntId, int ptMode, int & numberOfNodes) Line 494 C++
vtkCommon-9.1d.dll!vtkIncrementalOctreePointLocator::InsertUniquePoint(const double * point, __int64 & pntId) Line 1281 C++
vtkIO-9.1d.dll!vtkPLYReader::RequestData(vtkInformation * __formal, vtkInformationVector * * __formal, vtkInformationVector * outputVector) Line 536 C++
vtkCommon-9.1d.dll!vtkPolyDataAlgorithm::ProcessRequest(vtkInformation * request, vtkInformationVector * * inputVector, vtkInformationVector * outputVector) Line 87 C++
vtkCommon-9.1d.dll!vtkExecutive::CallAlgorithm(vtkInformation * request, int direction, vtkInformationVector * * inInfo, vtkInformationVector * outInfo) Line 734 C++
vtkCommon-9.1d.dll!vtkDemandDrivenPipeline::ExecuteData(vtkInformation * request, vtkInformationVector * * inInfo, vtkInformationVector * outInfo) Line 462 C++
vtkCommon-9.1d.dll!vtkCompositeDataPipeline::ExecuteData(vtkInformation * request, vtkInformationVector * * inInfoVec, vtkInformationVector * outInfoVec) Line 162 C++
vtkCommon-9.1d.dll!vtkDemandDrivenPipeline::ProcessRequest(vtkInformation * request, vtkInformationVector * * inInfoVec, vtkInformationVector * outInfoVec) Line 261 C++
vtkCommon-9.1d.dll!vtkStreamingDemandDrivenPipeline::ProcessRequest(vtkInformation * request, vtkInformationVector * * inInfoVec, vtkInformationVector * outInfoVec) Line 343 C++
vtkCommon-9.1d.dll!vtkDemandDrivenPipeline::UpdateData(int outputPort) Line 421 C++
vtkCommon-9.1d.dll!vtkStreamingDemandDrivenPipeline::Update(int port, vtkInformationVector * requests) Line 417 C++
vtkCommon-9.1d.dll!vtkStreamingDemandDrivenPipeline::Update(int port) Line 381 C++
vtkCommon-9.1d.dll!vtkAlgorithm::Update(int port) Line 1409 C++
vtkCommon-9.1d.dll!vtkAlgorithm::Update() Line 1403 C++
MRMLCore.dll!vtkMRMLModelStorageNode::ReadDataInternal(vtkMRMLNode * refNode) Line 301 C++
The error is that vtkIncrementalOctreePointLocator gets into an infinite loop when vtkPLYReader calls InsertUniquePoint
with the coordinates {-1.8040610551834106, -0.060864001512527466, 0.0000000000000000}
. It is outside the bounds that the locator was initialized with {0.0, 1.0, 0.0, 1.0, 0.0, 1.0}
but hundreds of similar points were added to the locator before.