vtkXMLWriter generates invalid file when encountering vtkVariantArray that can cause vtkXMLReader to segfault
-
vtkXMLWriter
generates incomplete array entry forvtkVariantArray
s (it is missing atype
attribute, but I suppose it should just skip them entirely):
<Array Name="data" NumberOfTuples="1" format="appended" offset="0" />
-
vtkXMLReader
is missing a null-pointer check around line 536 (since CreateArray may return null): https://gitlab.kitware.com/vtk/vtk/-/blob/b0f350b9e556d4ec41bbe8fc3bc11d83e967ec0d/IO/XML/vtkXMLReader.cxx#L536
Steps to reproduce
Run the following script (tested with VTK within ParaView v5.10.0-RC1, rev. b0f350b9)
import vtk
pd = vtk.vtkPolyData()
a = vtk.vtkVariantArray()
a.SetName('data')
a.InsertNextValue(vtk.vtkContourFilter())
pd.GetFieldData().AddArray(a)
writer = vtk.vtkXMLPolyDataWriter()
writer.SetFileName('temp.vtp')
writer.SetInputDataObject(pd)
writer.Update()
reader = vtk.vtkXMLPolyDataReader()
reader.SetFileName(writer.GetFileName())
reader.Update()
Output
( 0.333s) [paraview ] vtkXMLWriter.cxx:1563 WARN| vtkXMLPolyDataWriter (0x556de74cd830): Unsupported data type: 20
( 0.333s) [paraview ] vtkXMLWriter.cxx:1584 ERR| vtkXMLPolyDataWriter (0x556de74cd830): Data type size 0 not supported by VTK XML format.
( 0.333s) [paraview ] vtkXMLWriter.cxx:1475 WARN| vtkXMLPolyDataWriter (0x556de74cd830): Unsupported data type: 20
( 0.333s) [paraview ] vtkXMLWriter.cxx:1475 WARN| vtkXMLPolyDataWriter (0x556de74cd830): Unsupported data type: 20
( 0.333s) [paraview ] vtkXMLWriter.cxx:1475 WARN| vtkXMLPolyDataWriter (0x556de74cd830): Unsupported data type: 20
( 0.333s) [paraview ] vtkXMLWriter.cxx:1188 WARN| vtkXMLPolyDataWriter (0x556de74cd830): Not writing array 'data': Unsupported array type: vtkVariantArray
( 0.334s) [paraview ] vtkXMLDataElement.cxx:821 ERR| vtkXMLDataElement (0x556de74dce70): Missing word type attribute "type".
Loguru caught a signal: SIGSEGV
Stack trace:
24 0x556de4ff15ee /home/lhofmann/Libraries/paraview/ParaView-v5.10.0-RC1/bin/pvpython(+0x25ee) [0x556de4ff15ee]
23 0x7f5254dceb25 __libc_start_main + 213
22 0x556de4ff1f93 /home/lhofmann/Libraries/paraview/ParaView-v5.10.0-RC1/bin/pvpython(+0x2f93) [0x556de4ff1f93]
21 0x7f52532142e4 vtkPythonInterpreter::PyMain(int, char**) + 468
20 0x7f525211fae2 Py_Main + 60
19 0x7f52522c538a Py_RunMain + 986
18 0x7f525215bc79 PyRun_SimpleFileExFlags + 916
17 0x7f525215c893 /usr/lib/libpython3.9.so.1.0(+0x97893) [0x7f525215c893]
16 0x7f52522af55b /usr/lib/libpython3.9.so.1.0(+0x1ea55b) [0x7f52522af55b]
15 0x7f52522b3884 /usr/lib/libpython3.9.so.1.0(+0x1ee884) [0x7f52522b3884]
14 0x7f52522a3b13 PyEval_EvalCode + 35
13 0x7f52521ebe71 _PyEval_EvalCodeWithName + 81
12 0x7f52521ec489 /usr/lib/libpython3.9.so.1.0(+0x127489) [0x7f52521ec489]
11 0x7f52521f26f5 _PyEval_EvalFrameDefault + 21173
10 0x7f52521f6813 _PyObject_MakeTpCall + 739
9 0x7f525220e558 /usr/lib/libpython3.9.so.1.0(+0x149558) [0x7f525220e558]
8 0x7f520599bf21 /home/lhofmann/Libraries/paraview/ParaView-v5.10.0-RC1/lib/python3.9/site-packages/vtkmodules/vtkCommonExecutionModel.so(+0x2ef21) [0x7f520599bf21]
7 0x7f5252f11300 vtkStreamingDemandDrivenPipeline::Update(int, vtkInformationVector*) + 32
6 0x7f5252eaf609 vtkDemandDrivenPipeline::ProcessRequest(vtkInformation*, vtkInformationVector**, vtkInformationVector*) + 1257
5 0x7f5252f106d9 vtkStreamingDemandDrivenPipeline::ExecuteInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*) + 41
4 0x7f5252eb27b0 vtkExecutive::CallAlgorithm(vtkInformation*, int, vtkInformationVector**, vtkInformationVector*) + 80
3 0x7f52530a0cb9 vtkXMLReader::ProcessRequest(vtkInformation*, vtkInformationVector**, vtkInformationVector*) + 249
2 0x7f525309759e vtkXMLReader::RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*) + 46
1 0x7f52530a0653 vtkXMLReader::ReadXMLInformation() + 403
0 0x7f5254de3da0 /usr/lib/libc.so.6(+0x3cda0) [0x7f5254de3da0]
( 0.334s) [paraview ] :0 FATL| Signal: SIGSEGV