[Paraview] C++ Catalyst vtkSocket::Receive stuck in loop on Windows

klarmann at mechanik.tu-darmstadt.de klarmann at mechanik.tu-darmstadt.de
Wed Jul 12 05:38:46 EDT 2017


Hi,

I tested the PV master build now. Same thing happens as with PV 5.4 and 
5.2.
The example code works on linux but leads to a crash on windows.

In my opinion it is a bug in the vtkSocket regarding the windows 
specific code. I further investigated the problem and compared what 
happens. On linux an windows the method vtkSocket::Receive() gets called 
even after the connection is dropped by the Live side, so the call 
history should be the same.

The difference between linux and windows is that the function recv in 
line 606 of vtkSocket.cxx returns (if the connection is closed by the 
GUI) nRecvd=0 on linux and nRecvd=-1 (error code) on windows.

To fix the problem on windows I inserted the  following code at line 616 
of vtkSocket.cxx:

if ((nRecvd == vtkSocketErrorReturnMacro
	&& WSAGetLastError() == WSAECONNABORTED))
{
	return 0;
}


Maybe you can look into it.


Thanks,
Simon





Am 2017-07-11 20:17, schrieb Andy Bauer:
> Hi,
> 
> I tested on Linux (Ubuntu 16.04).
> 
> Best,
> Andy
> 
> On Tue, Jul 11, 2017 at 1:58 PM, <klarmann at mechanik.tu-darmstadt.de>
> wrote:
> 
>> Hi Andy,
>> 
>> I just tried my example on arch linux and it works as expected.
>> (ParaView 5.4.0-RC1)
>> 
>> Somehow I got the feeling it is an issue related to Windows. Just to
>> be sure, which OS did you choose to test the example code?
>> 
>> Thank you very much for your time and support,
>> Simon
>> 
>> Am 2017-07-11 17:02, schrieb Andy Bauer:
>> 
>> Hi Simon,
>> 
>> I tried with PV master (84f6e514) and couldn't replicate the crash.
>> I
>> was able to get the connection between the GUI and the CatalystTest
>> executable though since I saw the PVTrivialProducer come up in the
>> GUI.
>> 
>> Maybe you could try PV master and see if it works for you. Beyond
>> that
>> I think figuring out your issue would take a non-trivial amount of
>> effort to figure out.
>> 
>> Cheers,
>> Andy
>> 
>> On Tue, Jul 11, 2017 at 8:04 AM, Simon Klarmann
>> <klarmann at mechanik.tu-darmstadt.de> wrote:
>> 
>> Hi Andy,
>> 
>> I want to be able to close the connection from both sides. Closing
>> the connection from the Insitu side works by calling
>> vtkLiveInsituLink::DropLiveInsituConnection().
>> 
>> Closing the connection from the Live side, e.g. by closing the GUI,
>> causes my application to hang in the vtkSocket::Receive() method.
>> 
>> After enabling the Debug mode I get the following Error on the
>> Insitu side:
>> 
>> “ERROR: In
>> D:\build\ParaView-v5.4.0\VTK\Common\System\vtkSocket.cxx, line 572
>> 
>> vtkClientSocket (0000000008BFFC00): Socket error in call to send.
>> Eine bestehende Verbindung wurde softwaregesteuert durch den
>> Hostcomputer abgebrochen.”
>> 
>> „Eine bestehende Verbindung wurde softwaregesteuert durch den
>> Hostcomputer abgebrochen“
>> 
>> This seems to be a windows specific message notifying about a
>> software controlled termination of the connection. So the
>> information of the termination of the connection is somewhere
>> available. The method throwing this error is the vtkSocket::Send()
>> method.
>> 
>> This error shows up as soon as I close the connection from the Live
>> side (GUI) and then perform an InsituUpdate on the Insitu side.
>> Still after this message, my Insitu side runs into
>> vtkSocket::Receive() and get stuck there, trying to receive data.
>> 
>> Additional Info:
>> 
>> Performing the live visualization with the vtkCPPythonAdapter leads
>> to the same error message and a crash of the Insitu application.
>> 
>> Attached is a minimalistic working example. In both cases the error
>> happens.
>> 
>> Steps to reproduce:
>> 
>> 1.       Start Paraview ->Catalyst->Connect
>> 
>> 2.       Start the application, choose either 0 for python or 1 for
>> cpp, then the PVTrivialproducer should show up in Paraview
>> 
>> 3.       Close Paraview
>> 
>> 4.       Continue the application ->crash
>> 
>> I hope this helps a little bit to get an insight on what I did.
>> 
>> Thanks,
>> 
>> Simon
>> 
>> VON: Andy Bauer [mailto:andy.bauer at kitware.com [1]]
>> GESENDET: Montag, 10. Juli 2017 22:21
>> 
>> AN: Simon Klarmann
>> CC: paraview at paraview.org
>> BETREFF: Re: [Paraview] C++ Catalyst vtkSocket::Receive stuck in
>> 
>> loop on Windows
>> 
>> Hi,
>> 
>> Are you trying to close the connection from the in situ side? The
>> design was for the connection to be close through the GUI.
>> 
>> It's difficult to say what exactly is going on here without getting
>> fairly deep into the problem. Theoretically though it should be
>> possible to do the Live link in C++ as most of the Python routines
>> call wrapped C++ routines.
>> 
>> There should be some way to figure out the status of the connection
>> on the PV server (the builtin server if you're not connected to a
>> separate pvserver process) either the NotifyClientDisconnected()
>> method, or vtkLiveInsituLink::OnConnectionClosedEvent() or
>> vtkLiveInsituLink::DropLiveInsituConnection() member functions.
>> 
>> Cheers,
>> 
>> Andy
>> 
>> On Mon, Jul 10, 2017 at 10:34 AM, Simon Klarmann
>> <klarmann at mechanik.tu-darmstadt.de> wrote:
>> 
>> Sorry I think I have chosen the wrong reply method.
>> 
>> Hi Andy,
>> 
>> I already got rid of Python on both sides. CoProcessing with Live
>> connection is working by directly using the vtkLiveInsituLink (pure
>> C++ implementation).
>> 
>> Working with both Paraview 5.2  and 5.4.
>> 
>> My problem is closing the connection on the Live side (e.g. closing
>> Paraview). Doing so, my Insitu side hangs (when trying again to send
>> data, m_link->InsituUpdate, see below) in the receive method of the
>> vtkSocket class until at some point an integer underflow happens.
>> 
>> Closing the connection from the Insitu side everything works as
>> expected.
>> 
>> Are there any methods to directly check if the connection is still
>> alive?
>> 
>> Or is it a Windows specific problem?
>> 
>> Additionally the steps for the live connection in C++, for sure
>> there may be more elegant ways:
>> 
>> // Initialization
>> 
>> vtkCPProcessor  *m_proc = vtkCPProcessor::New();
>> 
>> m_proc->Initialize();
>> 
>> vtkLiveInsituLink  *m_link =
>> vtkLiveInsituLink::New();
>> 
>> m_link->SetInsituPort(22222);
>> 
>> m_link->SetHostname("localhost");
>> 
>> m_link->SetProcessType(vtkLiveInsituLink::INSITU);
>> 
>> vtkSMProxyManager  *m_spxm =
>> 
>> 
> vtkSMProxyManager::GetProxyManager()->GetActiveSessionProxyManager();
>> 
>> vtkSMProxy *m_px = m_spxm->NewProxy("sources",
>> "PVTrivialProducer");
>> 
>> vtkSMSourceProxy *m_spx =
>> vtkSMSourceProxy::SafeDownCast(m_px);
>> 
>> m_spxm->RegisterProxy("sources", m_spx);
>> 
>> vtkObjectBase *obase = m_spx->GetClientSideObject();
>> 
>> vtkPVTrivialProducer *prod =
>> 
>> vtkPVTrivialProducer::SafeDownCast(obase);
>> 
>> prod->SetOutput(m_toplot, m_time);    // m_toplot is
>> a vtkMultiBlockDataSet
>> 
>> m_link->Initialize(m_spxm);
>> 
>> //Update the live side
>> 
>> m_link->InsituUpdate(m_time, m_tstep);
>> 
>> m_spx->UpdatePipeline(m_time);
>> 
>> m_link->InsituPostProcess(m_time,m_tstep);
>> 
>> Thanks,
>> 
>> Simon
>> 
>> VON: Andy Bauer [mailto:andy.bauer at kitware.com]
>> GESENDET: Donnerstag, 6. Juli 2017 17:14
>> AN: Simon Klarmann
>> CC: paraview at paraview.org
>> BETREFF: Re: [Paraview] C++ Catalyst vtkSocket::Receive stuck in
>> 
>> loop on Windows
>> 
>> Hi Simon,
>> 
>> Is the Python dependency that you're trying to get rid of on the
>> Catalyst side or on the pvserver/GUI side? If I remember correctly
>> on the Catalyst side Python was required for the Live connection.
>> 
>> Cheers,
>> 
>> Andy
>> 
>> On Wed, Jul 5, 2017 at 10:11 AM, Simon Klarmann
>> <klarmann at mechanik.tu-darmstadt.de> wrote:
>> 
>> Dear Members,
>> 
>> I wanted to get rid of the dependency on Python. The connection by
>> pure C++ works just fine.
>> 
>> The problem occurs when establishing the live connection to
>> Paraview, closing Paraview and then try to send some data again.
>> 
>> I tracked it down to the vtkSocket class inside the method Receive.
>> After the connection is terminated on the Paraview side, e.g. by
>> closing Paraview, the call of vtkLiveInsituLink::InsituUpdate gets
>> stuck in the vtkSocket::Receive method. Even though I get a message
>> that the connection was terminated.
>> 
>> A temporary fix for my case was to replace in Line 609 of the
>> vtkSocket.cxx if (nRecvd == 0) with if (nRecvd <= 0), because on
>> disconnection the return value of nRecvd is -1. Then everything
>> works well.
>> 
>> I only used the following methods in the given order to transfer the
>> data:
>> 
>> vtkLiveInsituLink::InsituUpdate
>> 
>> vtkSMSourceProxy::UpdatePipeline
>> 
>> vtkLiveInsituLink::InsituPostProcess
>> 
>> Are there further steps to perform or is there a way to check if the
>> connection is still alive?
>> 
>> Operating System: Windows 7, Visual Studio 2017
>> 
>> Thanks,
>> 
>> Simon
>> 
>> Dipl.-Ing. Simon Klarmann
>> 
>> BAU- UND UMWELTINGENIEURWISSENSCHAFTEN
>> Technische Universität Darmstadt
>> 
>> Fachgebiet Festkörpermechanik
>> 
>> Tel.: +49 6151 16 [1] – 22642 [2]
>> 
>> Mail: klarmann at mechanik.tu-darmstadt.de
>> 
>> Franziska-Braun-Straße 7
>> 
>> Gebäude L5|01, Raum 542
>> 
>> 64287 Darmstadt
>> 
>> _______________________________________________
>> Powered by www.kitware.com [2] [3]
>> 
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html [3] [4]
>> 
>> Please keep messages on-topic and check the ParaView Wiki at:
>> http://paraview.org/Wiki/ParaView [4] [5]
>> 
>> Search the list archives at: http://markmail.org/search/?q=ParaView
>> [5]
>> [6]
>> 
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/paraview [6] [7]
>> 
>> Links:
>> ------
>> [1] http://re.com
>> [2] tel:+49%206151%201622642
>> [3] http://www.kitware.com
>> [4] http://www.kitware.com/opensource/opensource.html [3]
>> [5] http://paraview.org/Wiki/ParaView [4]
>> [6] http://markmail.org/search/?q=ParaView [5]
>> [7] http://public.kitware.com/mailman/listinfo/paraview [6]
> 
> 
> 
> Links:
> ------
> [1] tel:%2B49%206151%2016
> [2] http://www.kitware.com
> [3] http://www.kitware.com/opensource/opensource.html
> [4] http://paraview.org/Wiki/ParaView
> [5] http://markmail.org/search/?q=ParaView
> [6] http://public.kitware.com/mailman/listinfo/paraview


More information about the ParaView mailing list