Segmentation fault when using algorithm output returned from function

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Segmentation fault when using algorithm output returned from function

zmurphy
I have a class with a function which returns a vtkSmartPointer with a vtkAlgorithmOutput inside.
When attempting to pass this to an vtkAppendPolyData, I receive a segmentation fault.
Below is an example.

class MyClass {
    public:
        void setup() {
            //Do things to set up data
            _data = append->GetOutputPort(); //In this case, append is a different AppendPolyData
        }

        vtkSmartPointer<vtkAlgorithmOutput> output() { return _data; }

    protected:

        vtkSmartPointer<vtkAlgorithmOutput> _data;
}

Then in a different object which uses that class:

vtkSmartPointer<vtkAppendPolyData> collection = vtkSmartPointer<vtkAppendPolyData>::New();

for (auto& data : vectorOfMyClassObjects) {
    collection->AddInputConnection(data->output()); //Where the segfault happens
}

Does anyone know what might cause this or of any tips on how to diagnose it? I've run it through gdb to find where the segfault happens, but beyond that, I'm not sure what's wrong.
Reply | Threaded
Open this post in threaded view
|

Re: Segmentation fault when using algorithm output returned from function

zmurphy
After stepping through the code again with GDB, I've narrowed the segfault down to this line in vtkAlgorithm::GetExecutive:

vtkExecutive* e = this->CreateDefaultExecutive();

Looking at the code on GitHub, I'm unable to see why that particular line would cause a segmentation fault. I'm not even able to step into the CreateDefaultExecutive function.