I have the following code which calls AddArray() and it segfault.
if (euclidean_areas_exist) {
printf("xx00100\n");
vtkNew<vtkFloatArray> vtk_euclidean_areas;
vtk_euclidean_areas->SetName("eu_areas");
vtk_euclidean_areas->SetNumberOfComponents(1);
for (FloatContainer::const_iterator iter = euclidean_areas.begin();
iter != euclidean_areas.end(); ++iter) {
vtk_euclidean_areas->InsertNextTuple1((*iter));
}
printf("xx00101\n");
assert(source);
vtkCellData *cd = source->GetCellData();
assert(cd);
cd->AddArray(vtk_euclidean_areas);
printf("xx00102\n");
}
I have build a debug version of VTK 9.2.2 on Ubuntu 18.04 to trace the source of the crash, it appears to be somehow related to the call to Modified()
gdb stack trace
Program received signal SIGSEGV, Segmentation fault.
0xffffffffffffffff in ?? ()
(gdb) bt
#0 0xffffffffffffffff in ?? ()
#1 0x0000555555cf85a2 in vtkFieldData::AllocateArrays (this=0x555556afa490, num=1) at /data2/nyue/projects/VTK/9.2.2/VTK-9.2.2/Common/DataModel/vtkFieldData.cxx:437
#2 0x0000555555cf897e in vtkFieldData::SetArray (this=0x555556afa490, i=0, data=0x555556afce20) at /data2/nyue/projects/VTK/9.2.2/VTK-9.2.2/Common/DataModel/vtkFieldData.cxx:457
#3 0x0000555555cf951e in vtkFieldData::AddArray (this=0x555556afa490, array=0x555556afce20) at /data2/nyue/projects/VTK/9.2.2/VTK-9.2.2/Common/DataModel/vtkFieldData.cxx:672
#4 0x0000555555637453 in appendAttributes (h5f=@0x7fffffffcc18: 72057594037927936, vtkMeshName="/vtkOBJ", source=0x555556af9ed0)
at /home/nyue/projects/GeometryTools/GeometryTools_git/src/combine_vtk_hdf_to_vtp_main.cpp:103
#5 0x0000555555637f9c in main (argc=7, argv=0x7fffffffd068) at /home/nyue/projects/GeometryTools/GeometryTools_git/src/combine_vtk_hdf_to_vtp_main.cpp:185
(gdb) quit
A debugging session is active.
Inferior 1 [process 28829] will be killed.
Quit anyway? (y or n) y
Eclipse step through