[Bug 887] New: Segfault occurs on second connection to buffer port

http://bugs.orocos.org/show_bug.cgi?id=887

Summary: Segfault occurs on second connection to buffer port
Product: RTT
Version: rtt-trunk
Platform: All
OS/Version: Mac OS X
Status: NEW
Severity: normal
Priority: P3
Component: Corba
AssignedTo: orocos-dev [..] ...
ReportedBy: kiwi [dot] net [..] ...
CC: orocos-dev [..] ...
Estimated Hours: 0.0

Occurs when connecting _from_ a local buffer port _to_ a remote buffer port.
Does _not_ occur if connect _from_ same remote buffer port _to_ same local
buffer port. Test case attached. Demonstrated on Mac OS X Snow Leopard with RTT
svn (v1.12) and a custom version of RTT v1.10. Appears to only affect buffer
ports. The buffer port type is irrevelant (demonstrated with multiple types)

See gui.cpp in test case, but basically
{{{
#if 0
localPort.connectTo(remotePort); // FAILS with bug
#else
remotePort->connectTo(&localPort);
#endif
}}}

Run the deployer, run the GUI and let it quit, then re-run the GUI and it
segfaults with
{{{
Assertion failed: (ci->connected()), function connectTo, file
/g/o/rtt/src/PortInterface.cpp, line 121.
}}}

The difference is shown in the following log file excerpts
{{{
FAILS for local.connectTo(remote)
deployer
// *** NOTICE that the following line indicates the proxy is created in the
deployer ***
3.222 [ Debug ][deployer-corba-macosx::main()] Creating Corba BufferChannel
proxy.

// after 2nd GUI
22.586 [ Debug ][createBufferChannel] Creating Corba BufferChannel.
22.586 [ Debug ][createDataObject] Created 'Any' Expression server for type
double

1st GUI
0.030 [ Debug ][ControlTaskProxy] Fetching Objects of corbaservice:
0.030 [ Debug ][ControlTaskProxy] All Done.
0.031 [ Debug ][Logger] Creating Corba BufferChannel.

2nd GUI
0.020 [ Debug ][ControlTaskProxy] Fetching Objects of corbaservice:
0.020 [ Debug ][ControlTaskProxy] All Done.
Assertion failed: (ci->connected()), function connectTo, file
/g/o/rtt/src/PortInterface.cpp, line 121.

Program received signal SIGABRT, Aborted.
0x00007fff872cb0b6 in __kill ()
(gdb) bt
#0 0x00007fff872cb0b6 in __kill ()
#1 0x00007fff8736b9f6 in abort ()
#2 0x00007fff873589bc in __assert_rtn ()
#3 0x00000001002c3626 in RTT::PortInterface::connectTo (this=0x7fff5fbff078,
other=0x105805190) at /g/o/rtt/src/PortInterface.cpp:121
#4 0x000000010000592e in main ()
(gdb)

WORKS for remote.connectTo(local)
deployer
// *** NOTICE that the following line indicates the actual object is created in
the deployer ***
2.848 [ Debug ][createBufferChannel] Creating Corba BufferChannel.

GUI
0.024 [ Debug ][ControlTaskProxy] Fetching Objects of corbaservice:
0.024 [ Debug ][ControlTaskProxy] All Done.
// *** creates proxy ***
0.025 [ Debug ][OrbRunner] Creating Corba BufferChannel proxy.
0.025 [ Debug ][OrbRunner] Using scndry port to create bufferconnection.
}}}

ctaskbrowser does it correctly.

--
Configure bugmail: http://bugs.orocos.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
You are the assignee for the bug.
--
Orocos-Dev mailing list
Orocos-Dev [..] ...
http://lists.mech.kuleuven.be/mailman/listinfo/orocos-dev

[Bug 887] Segfault occurs on second connection to buffer port

http://bugs.orocos.org/show_bug.cgi?id=887

Peter Soetens <peter [..] ...> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|orocos-dev [..] ... |peter [..] ...
|ven.be |

[Bug 887] Segfault occurs on second connection to buffer port

http://bugs.orocos.org/show_bug.cgi?id=887

Peter Soetens <peter [..] ...> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |peter [..] ...

--- Comment #5 from Peter Soetens <peter [..] ...> 2011-10-21 16:24:28 CEST ---
(In reply to comment #2)
> Looks like it might be a bug in the corba port connection logic.
>
> Using a data port, a second GUI connection indicates that the cobra port is
> NOT connected, and it connects from scratch.
> Using a buffer port, a second GUI connection indicates that the cobra port is
> STILL connected, and attempts to resuse the connection. This fails.
>
> A workaround is to forcibly disconnect the _remote_ port before exiting the
> program.
>
> Demonstrated with v1.12 master on Mac OS X and Ubuntu 10.04.
>
> I could really use some help with the CORBA connection logic at this point. The
> only difference I notice is that in the CorbaPort connectTo() and
> createConnection() functions, the data port is narrowed to an
> AssignableExpression, whereas the buffer port is not. All other code appears to
> be the same.
>
> I can provide more logging if needed. I'm attaching a patch against RTT v1.12
> to provide trace outputs to the console. I've also modified the test case - see
> the "USE_BUFFER" define in the file. You can comment out this line to use data
> ports (which works) or buffer ports (which fail).

It's a known weakness that RTT 1.x can't detect disconnected CORBA ports
reliably. What the buffer_port.disconnect() does is disconnecting only that
port. Did you try to disconnect the connection:

buffer_port.connection().disconnect();

?

Which will disconnect all ports participating in that connection, so both the
remote and the local port.

There's not much logic in the connection management in 1.x, except that you
should always manually disconnect the connection object of a port in order to
do the proper cleanup...

With respect to the bug: the assertion needs to be replaced by a check, and a
new connection may be tried to be re-made (if possible).

Peter

[Bug 887] Segfault occurs on second connection to buffer port

On Oct 21, 2011, at 10:24 , Peter Soetens wrote:

>
> http://bugs.orocos.org/show_bug.cgi?id=887
>
> Peter Soetens <peter [..] ...> changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> CC| |peter [..] ...
>
> --- Comment #5 from Peter Soetens <peter [..] ...> 2011-10-21 16:24:28 CEST ---
> (In reply to comment #2)
>> Looks like it might be a bug in the corba port connection logic.
>>
>> Using a data port, a second GUI connection indicates that the cobra port is
>> NOT connected, and it connects from scratch.
>> Using a buffer port, a second GUI connection indicates that the cobra port is
>> STILL connected, and attempts to resuse the connection. This fails.
>>
>> A workaround is to forcibly disconnect the _remote_ port before exiting the
>> program.
>>
>> Demonstrated with v1.12 master on Mac OS X and Ubuntu 10.04.
>>
>> I could really use some help with the CORBA connection logic at this point. The
>> only difference I notice is that in the CorbaPort connectTo() and
>> createConnection() functions, the data port is narrowed to an
>> AssignableExpression, whereas the buffer port is not. All other code appears to
>> be the same.
>>
>> I can provide more logging if needed. I'm attaching a patch against RTT v1.12
>> to provide trace outputs to the console. I've also modified the test case - see
>> the "USE_BUFFER" define in the file. You can comment out this line to use data
>> ports (which works) or buffer ports (which fail).
>
> It's a known weakness that RTT 1.x can't detect disconnected CORBA ports
> reliably. What the buffer_port.disconnect() does is disconnecting only that
> port. Did you try to disconnect the connection:
>
> buffer_port.connection().disconnect();
>
> ?
>
> Which will disconnect all ports participating in that connection, so both the
> remote and the local port.
>
> There's not much logic in the connection management in 1.x, except that you
> should always manually disconnect the connection object of a port in order to
> do the proper cleanup...

I can try this next week (hopefully). I've only ever disconnected the port itself, not the connection ...

> With respect to the bug: the assertion needs to be replaced by a check, and a
> new connection may be tried to be re-made (if possible).
>
> Peter

So why does this work for data ports, but not buffer ports? That seems to be a key difference.
S
--
Orocos-Dev mailing list
Orocos-Dev [..] ...
http://lists.mech.kuleuven.be/mailman/listinfo/orocos-dev

[Bug 887] Segfault occurs on second connection to buffer port

http://bugs.orocos.org/show_bug.cgi?id=887

--- Comment #1 from S Roderick <kiwi [dot] net [..] ...> 2011-08-02 07:16:11 CEST ---
Created attachment 721
--> http://bugs.orocos.org/attachment.cgi?id=721
Test case with component and GUI

Might require some monkeying with CMake to get it to build with your own
installation ...