string arrays may cause vtkXMLUnstructuredGridWriter to produce corrupt vtu-files, which are unreadable or cause crash
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
When a string array is appended to the cell data of an unstructured grid, vtkXMLUnstructuredGridWriter may produce a corrupt vtu-file, depending on how long the strings are. I cannot tell at what length the issue shows up, but the longer the strings the sooner it happens. Even very simple models with just 304 cells can be affected. It doesn't matter whether the cell data is compressed or not and whether the data is binary or appended. Only ascii works.
Please see attached zip file, which contains:
- a test cpp file displaying how I produce the vtu-files
- a test msvc2010 project
- the source and resulting vtu files
Notes worth to be mentioned:
- When loading the compressed vtu-files the following error is reported:
ERROR: In ........\src\VTK\IO\vtkXMLDataReader.cxx, line 545 vtkXMLUnstructuredGridReader (000000000B2F7ED0): Cannot read cell data array "strings" from PointData in piece 0. The data array in the element may be too short.
- when loading the uncompressed vtu-files then the reading application crashes in the template function vtkXMLDataReaderReadArrayValues<vtkArrayIteratorTemplate>
I detected the issue already in version 5.8.0, it's still active in 5.10.0 and in 6.0 (git #02aef097).