crash writing vtp with degenerate cells (new in vtk9)
Code that uses vtkXMLPolyDataWriter that previously worked with vtk8 started crashing with vtk9. We created a workaround to that in this PR.
In discussions with @jcfr, we decided to post the issue here and flag it as a regression in VTK, since code that used to work (with a warning) now leads to a crash.
The issue is that this line in vtk 9.0.1 throws and error, which is caught and this->Cells
is set to nullptr
.
In vtk 8.1.2, the corresponding code generates a warning but processing continues and this->Cells
is valid.
Because this->Cells
is null in vtk 9.0.1, vtkXMLUnstructuredDataWriter
crashes with a stack trace like this:
1 std::vector<vtkPolyData_detail::TaggedCellId>::operator[] stl_vector.h 1043 0x7f3e1ff04516
2 vtkPolyData_detail::CellMap::GetTag vtkPolyDataInternals.h 239 0x7f3e1ff04325
3 vtkPolyData::GetCellType vtkPolyData.h 730 0x7f3e2012759a
4 vtkDataSet::GetCellTypes vtkDataSet.cxx 326 0x7f3e1ff39865
5 vtkXMLUnstructuredDataWriter::ProcessRequest vtkXMLUnstructuredDataWriter.cxx 166 0x7f3e1b31418e
6 vtkExecutive::CallAlgorithm vtkExecutive.cxx 746 0x7f3e1fe25449
7 vtkDemandDrivenPipeline::ExecuteData vtkDemandDrivenPipeline.cxx 462 0x7f3e1fe1cf92
...
IMO the correct behavior would be to restore the previous option of just printing a warning and continuing. It's not optimal to have degenerate cells in a vtkPolyData
, but it should not lead to a crash, especially since it worked before.