Incorectly formated .vtp file cause crash segfault when being displayed
An incorrectly formatted file can crash any application trying to display it and there is no way to avoid it. IMO I/O code should sanitize the input and just fail to read in that case:
ASCII version: a.vtp
Appended version: a.vtp
Backtrace when reading with ParaView:
Thread 1 "paraview" received signal SIGSEGV, Segmentation fault.
vtkPolyData::ComputeCellsBounds (this=0x55555d574f60) at /home/glow/dev/paraview/pv1/src/VTK/Common/DataModel/vtkPolyData.cxx:388
388 ptUses[pts[ptIdx]] = 1;
(gdb) bt
#0 vtkPolyData::ComputeCellsBounds (this=0x55555d574f60) at /home/glow/dev/paraview/pv1/src/VTK/Common/DataModel/vtkPolyData.cxx:388
#1 0x00007fffefe04da2 in vtkPolyData::GetCellsBounds (this=0x55555d574f60, bounds=0x7fffffffc240) at /home/glow/dev/paraview/pv1/src/VTK/Common/DataModel/vtkPolyData.cxx:401
#2 0x00007ffff3b6aeee in vtkCompositeDataDisplayAttributes::ComputeVisibleBoundsInternal (cda=0x55555ebff730, dobj=0x55555d574f60, bbox=0x7fffffffc4a0, parentVisible=true)
at /home/glow/dev/paraview/pv1/src/VTK/Rendering/Core/vtkCompositeDataDisplayAttributes.cxx:1024
#3 0x00007ffff3b6ae2a in vtkCompositeDataDisplayAttributes::ComputeVisibleBoundsInternal (cda=0x55555ebff730, dobj=0x55555ef58740, bbox=0x7fffffffc4a0, parentVisible=true)
at /home/glow/dev/paraview/pv1/src/VTK/Rendering/Core/vtkCompositeDataDisplayAttributes.cxx:1014
#4 0x00007ffff3b6ae2a in vtkCompositeDataDisplayAttributes::ComputeVisibleBoundsInternal (cda=0x55555ebff730, dobj=0x55555ef62bc0, bbox=0x7fffffffc4a0, parentVisible=true)
at /home/glow/dev/paraview/pv1/src/VTK/Rendering/Core/vtkCompositeDataDisplayAttributes.cxx:1014
#5 0x00007ffff3b6ac6c in vtkCompositeDataDisplayAttributes::ComputeVisibleBounds (cda=0x55555ebff730, dobj=0x55555ef62bc0, bounds=0x55555e417610)
at /home/glow/dev/paraview/pv1/src/VTK/Rendering/Core/vtkCompositeDataDisplayAttributes.cxx:988
#6 0x00007fffe6fbea7c in vtkGeometryRepresentation::GetBounds (dataObject=0x55555ef62bc0, bounds=0x55555e417610, cdAttributes=0x55555ebff730)
at /home/glow/dev/paraview/pv1/src/Remoting/Views/vtkGeometryRepresentation.cxx:557
#7 0x00007fffe6fc4f2e in vtkGeometryRepresentation::ComputeVisibleDataBounds (this=0x55555e417450) at /home/glow/dev/paraview/pv1/src/Remoting/Views/vtkGeometryRepresentation.cxx:1898
#8 0x00007fffe6fbe182 in vtkGeometryRepresentation::ProcessViewRequest (this=0x55555e417450, request_type=0x55555572e7d0, inInfo=0x5555583fc980, outInfo=0x55555ef5e6f0)
at /home/glow/dev/paraview/pv1/src/Remoting/Views/vtkGeometryRepresentation.cxx:412
#9 0x00007fffe6fd9727 in vtkGeometryRepresentationWithFaces::ProcessViewRequest (this=0x55555e417450, request_type=0x55555572e7d0, inInfo=0x5555583fc980, outInfo=0x55555ef5e6f0)
at /home/glow/dev/paraview/pv1/src/Remoting/Views/vtkGeometryRepresentationWithFaces.cxx:50
#10 0x00007fffe71601ab in vtkPVView::CallProcessViewRequest (this=0x555555a86af0, type=0x55555572e7d0, inInfo=0x5555583fc980, outVec=0x5555583f8bb0)
at /home/glow/dev/paraview/pv1/src/Remoting/Views/vtkPVView.cxx:570
#11 0x00007fffe715fa19 in vtkPVView::Update (this=0x555555a86af0) at /home/glow/dev/paraview/pv1/src/Remoting/Views/vtkPVView.cxx:455
#12 0x00007fffe7109e13 in vtkPVRenderView::Update (this=0x555555a86af0) at /home/glow/dev/paraview/pv1/src/Remoting/Views/vtkPVRenderView.cxx:1373
#13 0x00007fffe7108fa0 in vtkPVRenderView::ResetCamera (this=0x555555a86af0) at /home/glow/dev/paraview/pv1/src/Remoting/Views/vtkPVRenderView.cxx:1190
#14 0x00007fffe79ed5ad in vtkPVRenderViewCommand (arlu=0x555555a13d90, ob=0x555555a86af0, method=0x55555d572009 "ResetCamera", msg=..., resultStream=...)
at /home/glow/dev/paraview/pv1/build/CMakeFiles/vtkRemotingViewsCS/vtkPVRenderViewClientServer.cxx:229
#15 0x00007ffff4bb2398 in vtkClientServerInterpreter::CallCommandFunction
(this=0x555555a13d90, cname=0x7fffe72b801c "vtkPVRenderView", ptr=0x555555a86af0, method=0x55555d572009 "ResetCamera", msg=..., result=...)
This can be fixed in ComputeCellBounds
but this method is valid to assume point ids are valid in cells at this point.