[Paraview] Segmentation Fault when using the vtkPVDReader

Bogdan Daqui Herrera bdaqui at simscale.de
Tue Oct 28 11:04:08 EDT 2014


Hi Uktarsh, Burlen,

The PVD reader is finally working, thanks for the suggestions.

Initializing the environment before using the PVDReader is what did the trick.

Should it be useful to somebody else, you can use something akin to the following for initialization:
	static vtkSmartPointer<vtkPVOptions> options = vtkSmartPointer<vtkPVOptions>::New();
	char** execName = new char*[1];
	execName[0] = vtksys::SystemTools::DuplicateString("foobar_string");
	vtkInitializationHelper::Initialize( 1, execName, vtkProcessModule::PROCESS_CLIENT, options );

Useful examples are pvserver_common.h, pvpython.h (as suggested by Uktarsh) as well as vtkCPCxxHelper.cxx.

Is there any risk of a memory leak if the environment is initialized multiple times? For instance, if this is done within a class' constructor and this class is
instantiated several times during program execution, or will this initialization be confined to the live of the object?

Kind Regards,
Bogdan

On 10/27/2014 04:24 PM, Utkarsh Ayachit wrote:
> Bogdan,
> 
> The deal is this: the vtkPVDReader is designed for ParaView, it uses
> some of the core client-server infrastructure in ParaView. Thus, you
> can't use it directly is a VTK-based C++ executable without
> initializing ParaView environment. Initializing ParaView environment
> is not too complicated. Look at pvserver_common.h or pvpython.h, it
> should give you the necessary code. You basically use
> vtkInitializationHelper API to initialize the ParaView environment.
> 
> Hope that helps,
> 
> Utkarsh
> 
> 
> On Mon, Oct 27, 2014 at 11:14 AM, Burlen Loring <bloring at lbl.gov> wrote:
>> Unless something's changed in the pipeline recently that I'm unaware of,
>> when dealing with multiblock data you still need to force the composite data
>> pipeline first. that may or or may not be the cause of your segfault, but
>> you need to do it.
>>
>>
>> On 10/27/2014 03:56 AM, Bogdan Daqui Herrera wrote:
>>>
>>> Hi Burlen,
>>>
>>> Yes, it is a stand-alone C++ application, which makes use of VTK and
>>> Paraview as libraries, linking against them and calling functionality to
>>> interpret the data.
>>> I am not setting up any pipeline (as of now). Is this from the
>>> TestExodusTime or TestTemporalFractal examples. I will try adding this.
>>>
>>> Currently I need to read and traverse the dataset without adding any
>>> filters or processing the data. I it still needed to create a pipeline in
>>> this case?
>>>
>>> Kind regards,
>>> Bogdan
>>>
>>> On 10/24/2014 06:14 PM, Burlen Loring wrote:
>>>>
>>>> Hi Bogdan,
>>>>
>>>> You are writing a stand alone C++ app right? Are you setting up to run
>>>> the composite data pipeline as in the following example?
>>>>
>>>> 100   vtkCompositeDataPipeline* cexec=vtkCompositeDataPipeline::New();
>>>> 101   vtkAlgorithm::SetDefaultExecutivePrototype(cexec);
>>>> 102   cexec->Delete();
>>>>
>>>> Burlen
>>>>
>>>> On 10/23/2014 06:37 PM, Sebastien Jourdain wrote:
>>>>>
>>>>> Thanks Bogdan,
>>>>>
>>>>> that's not helping me but someone else might have some idea.
>>>>>
>>>>> Seb
>>>>>
>>>>> On Thu, Oct 23, 2014 at 12:19 PM, Bogdan Daqui Herrera
>>>>> <bdaqui at simscale.de <mailto:bdaqui at simscale.de>> wrote:
>>>>>
>>>>>      Certainly. I should mention, I am using a pre-compiled version of
>>>>> Paraview 4.1 bundled with Salome (Ubuntu package).
>>>>>
>>>>>      Here it is (using pReader->SetForceOutputTypeToMultiBlock(1)):
>>>>>      ERROR: In
>>>>> /misc/dn47/SALOME/PRODUCTS/7x/opt/Ubuntu.13.10.64/7.4.0/tmp/ParaView-4.1.0_SRC/ParaViewCore/VTKExtensions/Default/vtkXMLCollectionReader.cxx,
>>>>>      line 316
>>>>>      vtkPVDReader (0x6559e0): Error creating
>>>>> "vtkXMLMultiBlockDataReader" using vtkPVInstantiator.
>>>>>
>>>>>      Program received signal SIGSEGV, Segmentation fault.
>>>>>      0x00007ffff65c4270 in vtkXMLCollectionReader::ReadXMLDataImpl() ()
>>>>>         from
>>>>> /opt/salomeUbuntu_740/ParaView-4.1.0/lib/paraview-4.1/libvtkPVVTKExtensionsDefault-pv4.1.so.1
>>>>>      #0  0x00007ffff65c4270 in vtkXMLCollectionReader::ReadXMLDataImpl()
>>>>> ()
>>>>>         from
>>>>> /opt/salome_740/ParaView-4.1.0/lib/paraview-4.1/libvtkPVVTKExtensionsDefault-pv4.1.so.1
>>>>>      #1  0x00007ffff68cc128 in
>>>>> vtkXMLReader::RequestData(vtkInformation*, vtkInformationVector**,
>>>>> vtkInformationVector*) () from
>>>>>
>>>>> /opt/salome_740/ParaView-4.1.0/lib/paraview-4.1/libvtkIOXML-pv4.1.so.1
>>>>>      #2  0x00007ffff68cd35d in
>>>>> vtkXMLReader::ProcessRequest(vtkInformation*, vtkInformationVector**,
>>>>> vtkInformationVector*) () from
>>>>>
>>>>> /opt/salome_740/ParaView-4.1.0/lib/paraview-4.1/libvtkIOXML-pv4.1.so.1
>>>>>      #3  0x00007ffff7b97fd0 in
>>>>> vtkExecutive::CallAlgorithm(vtkInformation*, int, vtkInformationVector**,
>>>>> vtkInformationVector*) ()
>>>>>         from
>>>>> /opt/salome_740/ParaView-4.1.0/lib/paraview-4.1/libvtkCommonExecutionModel-pv4.1.so.1
>>>>>      #4  0x00007ffff7b93447 in
>>>>> vtkDemandDrivenPipeline::ExecuteData(vtkInformation*,
>>>>> vtkInformationVector**, vtkInformationVector*) ()
>>>>>         from
>>>>> /opt/salome_740/ParaView-4.1.0/lib/paraview-4.1/libvtkCommonExecutionModel-pv4.1.so.1
>>>>>      #5  0x00007ffff7b91181 in
>>>>> vtkCompositeDataPipeline::ExecuteData(vtkInformation*,
>>>>> vtkInformationVector**, vtkInformationVector*) ()
>>>>>         from
>>>>> /opt/salome_740/ParaView-4.1.0/lib/paraview-4.1/libvtkCommonExecutionModel-pv4.1.so.1
>>>>>      #6  0x00007ffff7b95bb1 in
>>>>> vtkDemandDrivenPipeline::ProcessRequest(vtkInformation*,
>>>>> vtkInformationVector**, vtkInformationVector*) ()
>>>>>         from
>>>>> /opt/salome_740/ParaView-4.1.0/lib/paraview-4.1/libvtkCommonExecutionModel-pv4.1.so.1
>>>>>      #7  0x00007ffff7ba8c21 in
>>>>> vtkStreamingDemandDrivenPipeline::ProcessRequest(vtkInformation*,
>>>>> vtkInformationVector**, vtkInformationVector*) ()
>>>>>         from
>>>>> /opt/salome_740/ParaView-4.1.0/lib/paraview-4.1/libvtkCommonExecutionModel-pv4.1.so.1
>>>>>      #8  0x00007ffff7b9486d in vtkDemandDrivenPipeline::UpdateData(int)
>>>>> ()
>>>>>         from
>>>>> /opt/salome_740/ParaView-4.1.0/lib/paraview-4.1/libvtkCommonExecutionModel-pv4.1.so.1
>>>>>      #9  0x00007ffff7ba9765 in
>>>>> vtkStreamingDemandDrivenPipeline::Update(int) ()
>>>>>         from
>>>>> /opt/salome_740/ParaView-4.1.0/lib/paraview-4.1/libvtkCommonExecutionModel-pv4.1.so.1
>>>>>      #10 0x0000000000414fbf in testing::TestingIO::read (this=0x652b30,
>>>>> fileName=..., pMultiBlockDataSet=...)
>>>>>          at /home/.../someProject/src/testing.cpp:85
>>>>>
>>>>>
>>>>>      Please let me know if you need something additional
>>>>>      On 10/23/2014 07:51 PM, Sebastien Jourdain wrote:
>>>>>      > If you provide the stack trace, that may be helpful.
>>>>>      >
>>>>>      > Seb
>>>>>      >
>>>>>      > On Thu, Oct 23, 2014 at 10:36 AM, Bogdan Daqui Herrera
>>>>> <bdaqui at simscale.de <mailto:bdaqui at simscale.de> <mailto:bdaqui at simscale.de
>>>>>      <mailto:bdaqui at simscale.de>>> wrote:
>>>>>      >
>>>>>      >     Hi Seb,
>>>>>      >
>>>>>      >     Thanks for the quick reply. Yes the project is managed with
>>>>> CMake. I have not however been able to find the relevant posts by Marcus (in
>>>>> the users
>>>>>      list). Is
>>>>>      >     that in the users or developers mailing list?
>>>>>      >
>>>>>      >     It does sound like it could be a problem with some
>>>>> initialization, as you can see below.
>>>>>      >
>>>>>      >     One short update, it looks like setting
>>>>> ForceMultiBlockDataSet Output with:
>>>>>      >     pReader->SetForceOutputTypeToMultiBlock(1);
>>>>>      >     leads to the segmentation fault at Update() (The deepcopy is
>>>>> never reached). With or without setting the previous line, the error
>>>>>      >     vtkPVDReader (0x1cb49e0): Error creating
>>>>> "vtkXMLMultiBlockDataReader" using vtkPVInstantiator.
>>>>>      >
>>>>>      >     The code looks like this now:
>>>>>      >             vtkSmartPointer < vtkPVDReader > pReader =
>>>>> vtkSmartPointer < vtkPVDReader >::New();
>>>>>      >             pReader->SetFileName("/some/file.pvd");
>>>>>      >             pReader->Update(); (where the error is triggered)
>>>>>      >
>>>>>      >     Kind Regards,
>>>>>      >     Bogdan
>>>>>      >
>>>>>      >     On 10/23/2014 04:47 PM, Sebastien Jourdain wrote:
>>>>>      >     > Hi Bogdan,
>>>>>      >     >
>>>>>      >     > here are some issue in your code:
>>>>>      >     >
>>>>>      >     > vtkSmartPointer <vtkPVDReader> pReader =
>>>>> vtkPVDReader::New(); // <== Memory LEAK
>>>>>      >     > // Should be either
>>>>>      >     > // vtkNew<vtkPVDReader> pReader;
>>>>>      >     > // vtkSmartPointer<vtkPVDReader> pReader =
>>>>> vtkSmartPointer<vtkPVDReader>::New()
>>>>>      >     >
>>>>>      >     > Then here on a "NULL" object you try to call a method.
>>>>>      >     >
>>>>>      >     > vtkMultiBlockDataSet*
>>>>> pMultiBlockDataSet->DeepCopy(vtkMultiBlockDataSet::SafeDownCast(pReader->GetOutputDataObject(0)));
>>>>>      >     >
>>>>>      >     > Should be something like that:
>>>>>      >     >
>>>>>      >     > vtkNew< vtkMultiBlockDataSet > pMultiBlockDataSet;
>>>>>      >     >
>>>>> pMultiBlockDataSet->DeepCopy(vtkMultiBlockDataSet::SafeDownCast(pReader->GetOutputDataObject(0)));
>>>>>      >     >
>>>>>      >     > Then you might have some other issue where pReader output
>>>>> being empty/null, but for that I don't know.
>>>>>      >     >
>>>>>      >     > Are you managing your project with CMake? Did you include
>>>>> the necessary file with the proper dependency declaration. This seems to be
>>>>> related to
>>>>>      the factory not
>>>>>      >     > being properly initialized. You can search the mailing
>>>>> list, Marcus did answer several questions about that.
>>>>>      >     >
>>>>>      >     > Seb
>>>>>      >     >
>>>>>      >     >
>>>>>      >     >
>>>>>      >     > On Thu, Oct 23, 2014 at 7:26 AM, Bogdan Daqui Herrera
>>>>> <bdaqui at simscale.de <mailto:bdaqui at simscale.de> <mailto:bdaqui at simscale.de
>>>>>      <mailto:bdaqui at simscale.de>> <mailto:bdaqui at simscale.de
>>>>> <mailto:bdaqui at simscale.de>
>>>>>      >     <mailto:bdaqui at simscale.de <mailto:bdaqui at simscale.de>>>>
>>>>> wrote:
>>>>>      >     >
>>>>>      >     >     Hello all,
>>>>>      >     >
>>>>>      >     >     I am attempting to write some code in c++ which uses
>>>>> the vtkPVDReader from the paraview library to read a series of vtm files.
>>>>> However I am
>>>>>      >     encountering some
>>>>>      >     >     problems and I am not sure whether there is something I
>>>>> am missing or whether this could be a bug.
>>>>>      >     >
>>>>>      >     >     I am trying to use the reader in the following manner:
>>>>>      >     >     My Code:
>>>>>      >     >             vtkSmartPointer <vtkPVDReader> pReader =
>>>>> vtkPVDReader::New();
>>>>>      >     >             pReader->SetForceOutputTypeToMultiBlock(1);
>>>>>      >     >             pReader->SetFileName("/some/fileName.pvd");
>>>>>      >     >             pReader->Update();
>>>>>      >     >             vtkMultiBlockDataSet*
>>>>> pMultiBlockDataSet->DeepCopy(vtkMultiBlockDataSet::SafeDownCast(pReader->GetOutputDataObject(0)));
>>>>>      >     >
>>>>>      >     >     Error:
>>>>>      >     >             The error occurs at Update() with the following
>>>>> result:
>>>>>      >     >             ERROR: In
>>>>> /misc/dn47/SALOME/PRODUCTS/7x/opt/Ubuntu.13.10.64/7.4.0/tmp/ParaView-4.1.0_SRC/ParaViewCore/VTKExtensions/Default
>>>>>      >     >             /vtkXMLCollectionReader.cxx, line 316
>>>>>      >     >             vtkPVDReader (0x224d9e0): Error creating
>>>>> "vtkXMLMultiBlockDataReader" using vtkPVInstantiator.
>>>>>      >     >             Segmentation fault
>>>>>      >     >
>>>>>      >     >     Possible error Source
>>>>>      >     >     The code concerning line 316 from
>>>>> vtkXMLCollectionReader.cxx is:
>>>>>      >     >
>>>>>      >     >           // Use the instantiator to create the reader.
>>>>>      >     >           vtkObject* o =
>>>>> vtkPVInstantiator::CreateInstance(rname);
>>>>>      >     >           vtkXMLReader* reader =
>>>>> vtkXMLReader::SafeDownCast(o);
>>>>>      >     >           this->Internal->Readers[index] = reader;
>>>>>      >     >           if(reader)
>>>>>      >     >             {
>>>>>      >     >             reader->Delete();
>>>>>      >     >             }
>>>>>      >     >           else
>>>>>      >     >             {
>>>>>      >     >             // The class was not registered with the
>>>>> instantiator.
>>>>>      >     >             vtkErrorMacro("Error creating \"" << rname
>>>>>      >     >                           << "\" using
>>>>> vtkPVInstantiator.");
>>>>>      >     >             if(o)
>>>>>      >     >               {
>>>>>      >     >               o->Delete();
>>>>>      >     >               }
>>>>>      >     >             }
>>>>>      >     >           }
>>>>>      >     >
>>>>>      >     >     I have isolated the following lines and tested them
>>>>> independently:
>>>>>      >     >           vtkObject* o =
>>>>> vtkPVInstantiator::CreateInstance(rname);
>>>>>      >     >           vtkXMLReader* reader =
>>>>> vtkXMLReader::SafeDownCast(o);
>>>>>      >     >
>>>>>      >     >     The pointer "vtkObject* o" is NULL regardless of the
>>>>> class name I pass to instantiate, and I can imagine something like that
>>>>> happening in the
>>>>>      library,
>>>>>      >     too and
>>>>>      >     >     causing the segmentation fault, when calling a
>>>>> SafeDownCast(o) (which is NULL).
>>>>>      >     >
>>>>>      >     >
>>>>>      >     >     Any suggestions on how to deal with this problem or if
>>>>> you would be so kind to point me to an example for an alternative solution
>>>>> (Could be
>>>>>      >     vtkFileSeriesReader,
>>>>>      >     >     but this fails, as well in my case) would be
>>>>> appreciated.
>>>>>      >     >
>>>>>      >     >     Kind Regards,
>>>>>      >     >     Bogdan
>>>>>      >     >
>>>>>      >     >     P.S.: Using the PVDReader from python code works
>>>>> flawlessly, which is also quite confusing, as to why it would fail in the
>>>>> C++ code.
>>>>>      >     >
>>>>>      >     >     --
>>>>>      >     >     Bogdan Daqui
>>>>>      >     >     Software Development
>>>>>      >     >
>>>>>      >     >     SimScale GmbH
>>>>>      >     >     Lichtenbergstraße 8
>>>>>      >     >     85748 Garching bei München
>>>>>      >     >
>>>>>      >     >     Phone: +49 (0)89 3398 4078
>>>>>      >     >     Email: bdaqui at simscale.de <mailto:bdaqui at simscale.de>
>>>>> <mailto:bdaqui at simscale.de <mailto:bdaqui at simscale.de>>
>>>>> <mailto:bdaqui at simscale.de
>>>>>      <mailto:bdaqui at simscale.de> <mailto:bdaqui at simscale.de
>>>>> <mailto:bdaqui at simscale.de>>>
>>>>>      >     >
>>>>>      >     >     Amtsgericht München, HRB 201813
>>>>>      >     >     Geschäftsführer: Vincenz Dölle & David Heiny
>>>>>      >     >
>>>>>      >     >     http://www.simscale.de
>>>>>      >     >     _______________________________________________
>>>>>      >     >     Powered by www.kitware.com <http://www.kitware.com>
>>>>> <http://www.kitware.com> <http://www.kitware.com>
>>>>>      >     >
>>>>>      >     >     Visit other Kitware open-source projects at
>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>      >     >
>>>>>      >     >     Please keep messages on-topic and check the ParaView
>>>>> Wiki at: http://paraview.org/Wiki/ParaView
>>>>>      >     >
>>>>>      >     >     Follow this link to subscribe/unsubscribe:
>>>>>      >     >     http://public.kitware.com/mailman/listinfo/paraview
>>>>>      >     >
>>>>>      >     >
>>>>>      >
>>>>>      >
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Powered by www.kitware.com
>>>>>
>>>>> Visit other Kitware open-source projects at
>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>
>>>>> Please keep messages on-topic and check the ParaView Wiki at:
>>>>> http://paraview.org/Wiki/ParaView
>>>>>
>>>>> Follow this link to subscribe/unsubscribe:
>>>>> http://public.kitware.com/mailman/listinfo/paraview
>>
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the ParaView Wiki at:
>> http://paraview.org/Wiki/ParaView
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/paraview


More information about the ParaView mailing list