View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015813ParaView(No Category)public2015-10-29 06:042015-12-16 17:00
ReporterNico Schlömer 
Assigned ToJoachim Pouderoux 
PriorityhighSeverityminorReproducibilityhave not tried
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version5.0 
Summary0015813: SEGFAULT: vtkExodusIIWriter Write
DescriptionWith Python, VTK 6.2, the following script produces a segfault:
```
import numpy as np
import vtk

points = np.array([
    [-0.5, -0.5, -5. ],
    [-0.5, 0.5, -5. ],
    [ 0.5, -0.5, -5. ],
    [-0.5, -0.5, 5. ],
    [ 0.5, 0.5, -5. ],
    [ 0.5, 0.5, 5. ],
    [-0.5, 0.5, 5. ],
    [ 0.5, -0.5, 5. ]
    ])

cells = np.array([
    [0, 1, 2, 3],
    [1, 4, 2, 5],
    [1, 2, 3, 5],
    [1, 3, 6, 5],
    [2, 3, 5, 7]
    ])

mesh = vtk.vtkUnstructuredGrid()

vtk_points = vtk.vtkPoints()
for point in points:
    vtk_points.InsertNextPoint(point[0], point[1], point[2])
mesh.SetPoints(vtk_points)

for cell in cells:
    pts = vtk.vtkIdList()
    pts.SetNumberOfIds(4)
    # Get the connectivity for this element.
    for k, node_index in enumerate(cell):
        pts.InsertId(k, node_index)
    mesh.InsertNextCell(vtk.VTK_TETRA, pts)

# works fine:
# writer = vtk.vtkUnstructuredGridWriter()
# writer.SetFileTypeToASCII()
# writer.SetFileName('test.vtk')

writer = vtk.vtkExodusIIWriter()
writer.SetFileName('test.e')

writer.SetInputData(mesh)
writer.Write() # Segmentation fault (core dumped)
```
TagsNo tags attached.
ProjectTBD
Topic Name
Typecrash
Attached Files

 Relationships

  Notes
(0035446)
Joachim Pouderoux (developer)
2015-11-13 05:22

I tried the following C++ version on git master and it works fine.
Does it crash with 6.2?

-----------------------------------

#include <vtkNew.h>
#include <vtkPoints.h>
#include <vtkCellArray.h>
#include <vtkUnstructuredGrid.h>
#include <vtkExodusIIWriter.h>

int main(int argc, char* argv[])
{
  double pts[] = {
   -0.5, -0.5, -5.,
    -0.5, 0.5, -5.,
    0.5, -0.5, -5.,
    -0.5, -0.5, 5.,
    0.5, 0.5, -5.,
    0.5, 0.5, 5.,
    -0.5, 0.5, 5.,
    0.5, -0.5, 5.
    };
   vtkIdType ids[] = {
     0, 1, 2, 3,
     1, 4, 2, 5,
     1, 2, 3, 5,
     1, 3, 6, 5,
     2, 3, 5, 7
  };

  vtkNew<vtkPoints> points;
  points->SetNumberOfPoints(8);
  for (int i = 0; i < 8; i++)
    {
    points->SetPoint(i, pts + i * 3);
    }
  vtkNew<vtkUnstructuredGrid> grid;
  grid->SetPoints(points.Get());
  
  for (int i = 0; i < 5; i++)
    {
    grid->InsertNextCell(VTK_TETRA, 4, ids + i * 4);
    }

  vtkNew<vtkExodusIIWriter> writer;
  writer->SetFileName("test.e");
  writer->SetInputData(grid.Get());
  writer->Write();

  return EXIT_SUCCESS;
}
(0035447)
Joachim Pouderoux (developer)
2015-11-13 05:26

The ExodusII writer has changed a lot since VTK 6.2. Please consider updating VTK.
By the way it is more a VTK potential issue than a ParaView one - this ticket should have been open on the VTK mantis project.
(0035529)
Nico Schlömer (reporter)
2015-12-10 06:35

Thanks for the reply!

I've tested the original snippet with the latest VTK from git master and it still segfaults.

(Btw I've added a PPA for VTK, updated nightly from git master; see <https://launchpad.net/~nschloe/+archive/ubuntu/vtk-nightly/+packages>. [^])
(0035530)
Nico Schlömer (reporter)
2015-12-10 06:40

The C++ snippet you provide also segfaults for me on the latest Git master.
The backtrace:
```
(gdb) backtrace
#0 0x00007ffff5e98c1b in vtkMultiProcessController::GetNumberOfProcesses() ()
   from /usr/lib/x86_64-linux-gnu/libvtkParallelCore-6.3.so.6.3
#1 0x00007ffff7bcec3f in vtkPExodusIIWriter::CheckParameters() ()
   from /usr/lib/x86_64-linux-gnu/libvtkIOParallelExodus-6.3.so.6.3
#2 0x00007ffff774f2af in vtkExodusIIWriter::WriteData() () from /usr/lib/x86_64-linux-gnu/libvtkIOExodus-6.3.so.6.3
#3 0x00007ffff774219a in vtkExodusIIWriter::RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) ()
   from /usr/lib/x86_64-linux-gnu/libvtkIOExodus-6.3.so.6.3
#4 0x00007ffff5350d70 in vtkExecutive::CallAlgorithm(vtkInformation*, int, vtkInformationVector**, vtkInformationVector*) ()
   from /usr/lib/x86_64-linux-gnu/libvtkCommonExecutionModel-6.3.so.6.3
#5 0x00007ffff534ad87 in vtkDemandDrivenPipeline::ExecuteData(vtkInformation*, vtkInformationVector**, vtkInformationVector*)
    () from /usr/lib/x86_64-linux-gnu/libvtkCommonExecutionModel-6.3.so.6.3
#6 0x00007ffff5348556 in vtkCompositeDataPipeline::ExecuteData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) () from /usr/lib/x86_64-linux-gnu/libvtkCommonExecutionModel-6.3.so.6.3
#7 0x00007ffff534d793 in vtkDemandDrivenPipeline::ProcessRequest(vtkInformation*, vtkInformationVector**, vtkInformationVector*) () from /usr/lib/x86_64-linux-gnu/libvtkCommonExecutionModel-6.3.so.6.3
#8 0x00007ffff536b281 in vtkStreamingDemandDrivenPipeline::ProcessRequest(vtkInformation*, vtkInformationVector**, vtkInformationVector*) () from /usr/lib/x86_64-linux-gnu/libvtkCommonExecutionModel-6.3.so.6.3
0000009 0x00007ffff534c12d in vtkDemandDrivenPipeline::UpdateData(int) ()
   from /usr/lib/x86_64-linux-gnu/libvtkCommonExecutionModel-6.3.so.6.3
#10 0x00007ffff5369125 in vtkStreamingDemandDrivenPipeline::Update(int) ()
   from /usr/lib/x86_64-linux-gnu/libvtkCommonExecutionModel-6.3.so.6.3
0000011 0x00007ffff74b22ee in vtkWriter::Write() () from /usr/lib/x86_64-linux-gnu/libvtkIOCore-6.3.so.6.3
#12 0x00000000004018a2 in main ()
```
(0035531)
Joachim Pouderoux (developer)
2015-12-10 07:13

Oh I think I see the problem.
Stay tuned.
(0035532)
Joachim Pouderoux (developer)
2015-12-10 07:25

You have compiled VTK with the parallel version of the Exodus writer (Module_vtkIOParallelExodus). When this option is turned on, the object factory returns a vtkPExodusWriter (the parallel version) when you ask for a vtkExodusWriter. However this parallel version requires a global multiprocessor controler to be set - and if it is not the case it will do a call on a null pointer.
I will make a fix for this soon.
In the meanwhile, you can create a DummyController and set it as the global controller:

#include "vtkDummyController.h"

int main(int argc, char** argv)
{
  vtkNew<vtkDummyController> controller;
  controller->Initialize(&argc, &argv, 1);
  vtkMultiProcessController::SetGlobalController(controller.Get());

  ... then the rest of the code

}

Let me know if it does the trick.
(0035533)
Joachim Pouderoux (developer)
2015-12-10 07:41
edited on: 2015-12-10 07:41

This patch fixes the problem without using a dummy controller or whatever:
https://gitlab.kitware.com/vtk/vtk/merge_requests/995 [^]

(0035535)
Joachim Pouderoux (developer)
2015-12-10 10:51

For information the patch has been merged in VTK git master!
(0035536)
Nico Schlömer (reporter)
2015-12-10 11:17

Wow, that was fast! I rebuilt and can confirm the fix. Feel free to close.
(0035537)
Joachim Pouderoux (developer)
2015-12-10 11:19

Thanks! This is just Kitwareans efficiency ;)
(0035580)
Alan Scott (manager)
2015-12-16 17:00

Tested 5.0.0-RC2, Linux, local server.

 Issue History
Date Modified Username Field Change
2015-10-29 06:04 Nico Schlömer New Issue
2015-11-13 05:22 Joachim Pouderoux Note Added: 0035446
2015-11-13 05:26 Joachim Pouderoux Note Added: 0035447
2015-12-10 06:35 Nico Schlömer Note Added: 0035529
2015-12-10 06:40 Nico Schlömer Note Added: 0035530
2015-12-10 07:13 Joachim Pouderoux Note Added: 0035531
2015-12-10 07:25 Joachim Pouderoux Note Added: 0035532
2015-12-10 07:41 Joachim Pouderoux Note Added: 0035533
2015-12-10 07:41 Joachim Pouderoux Note Edited: 0035533
2015-12-10 10:51 Joachim Pouderoux Note Added: 0035535
2015-12-10 11:17 Nico Schlömer Note Added: 0035536
2015-12-10 11:19 Joachim Pouderoux Note Added: 0035537
2015-12-10 11:19 Joachim Pouderoux Status backlog => gatekeeper review
2015-12-10 11:19 Joachim Pouderoux Resolution open => fixed
2015-12-10 11:19 Joachim Pouderoux Assigned To => Joachim Pouderoux
2015-12-11 14:55 Utkarsh Ayachit Status gatekeeper review => customer review
2015-12-11 14:55 Utkarsh Ayachit Fixed in Version => 5.0
2015-12-16 17:00 Alan Scott Note Added: 0035580
2015-12-16 17:00 Alan Scott Status customer review => closed


Copyright © 2000 - 2018 MantisBT Team