Corba and pass by reference Method

Hello,

I'm working with the last version of the repository rtt-mainline-2.0 under windows (There are some symbols missing with win32, Jean Sreng will soon update his repository to fix this).

I have an issue when calling a remote method which take argument by value (see attached file). The value of the argument is lost while building the RemoteMethod object.

I have a method :

void ReadConstRefStr(const std::string& message)

I add this method to the operation :

this->addOperation("ReadConstRefStr", &Test::ReadConstRefStr, this, RTT::OwnThread).arg("string", "new message");

and I call it from another process :

RTT::Method<void(const std::string&)> SendConstRefStr = this->getPeer(this->getPeerList()[0])->getOperation("ReadConstRefStr");
SendConstRefStr(test); // send to remote user

The problem lies in the way the reference to the object is handled. When the MethodC is initiliazed (line 318 in RemoteMethod.hpp) it stores a reference to an object which is pointed to by the DataSourceStorage of the RemoteMethod. But when the RemoteMethod is called, the pointer of DataSourceStorage is changed (call to this->store in RemoteMethodImpl::call_impl in RemoteMethod.hpp) but the arguments of MethodC still point to the old object.

This issue does not happen when an argument is pass by value, since there's only copy (template<class T> class Astore), and no pointer copy (use Astore<T&>).

I have also an another issue in my example I had to declare a new CorbaLibPlugin since this plugin only appear in CorbaLib.cpp and the loader was removed recently (commit 48dcfe758ad305943c58). I may have misunderstood, but I think CorbaLibPlugin must be declared in CorbaLib.hpp.

Regards, Mathieu

AttachmentSize
main.cpp5.21 KB

Corba and pass by reference Method

On Thursday 29 July 2010 16:37:36 mathieu [dot] gautier [..] ... wrote:
> Hello,
>
> I'm working with the last version of the repository rtt-mainline-2.0 under
> windows (There are some symbols missing with win32, Jean Sreng will soon
> update his repository to fix this).

Thanks. We're still fixing bugs on a daily basis. I'm preparing them to be
pushed to git[hub/orious].

>
> I have an issue when calling a remote method which take argument by value
> (see attached file). The value of the argument is lost while building the
> RemoteMethod object.
>
> I have a method :
> &#10;&gt; void ReadConstRefStr(const std::string&amp; message)&#10;&gt;
>
> I add this method to the operation :
> &#10;&gt; this-&gt;addOperation(&quot;ReadConstRefStr&quot;, &amp;Test::ReadConstRefStr, this,&#10;&gt;  RTT::OwnThread).arg(&quot;string&quot;, &quot;new message&quot;);
>
> and I call it from another process :
>
> &#10;&gt; RTT::Method&lt;void(const std::string&amp;)&gt; SendConstRefStr =&#10;&gt;  this-&gt;getPeer(this-&gt;getPeerList()[0])-&gt;getOperation(&quot;ReadConstRefStr&quot;);&#10;&gt;  SendConstRefStr(test); // send to remote user&#10;&gt;
>
> The problem lies in the way the reference to the object is handled. When
> the MethodC is initiliazed (line 318 in RemoteMethod.hpp) it stores a
> reference to an object which is pointed to by the DataSourceStorage of the
> RemoteMethod. But when the RemoteMethod is called, the pointer of
> DataSourceStorage is changed (call to this->store in
> RemoteMethodImpl::call_impl in RemoteMethod.hpp) but the arguments of
> MethodC still point to the old object.
>
> This issue does not happen when an argument is pass by value, since there's
> only copy (template<class T> class Astore), and no pointer copy (use
> Astore<T&>).

I coincidentally fixed a related issue yesterday in this class, but we probably
need an extra unit test to cover/check your case too. One of the problems is
that a clone is made during call or send and that the risk is that store is
storing to the original, or that the datasources read from the original
instead of the new clone. Certainly needs more testing/fixing.

>
> I have also an another issue in my example I had to declare a new
> CorbaLibPlugin since this plugin only appear in CorbaLib.cpp and the
> loader was removed recently (commit 48dcfe758ad305943c58). I may have
> misunderstood, but I think CorbaLibPlugin must be declared in
> CorbaLib.hpp.

Normally not, at least not on Linux. CorbaLibPlugin is used only internally in
the orocos-corba transport library. Did you need to set the RTT_CORBA_DLL
attribute on the CorbaLibPlugin class to resolve a link error ?

Peter

Corba and pass by reference Method

Quote:

I coincidentally fixed a related issue yesterday in this class, but we probably
need an extra unit test to cover/check your case too. One of the problems is
that a clone is made during call or send and that the risk is that store is
storing to the original, or that the datasources read from the original
instead of the new clone. Certainly needs more testing/fixing.

I tried with the last version from Jean's repository which was synchronized with the master from gitorious today, and I have still this issue.

Quote:

Normally not, at least not on Linux. CorbaLibPlugin is used only internally in
the orocos-corba transport library. Did you need to set the RTT_CORBA_DLL
attribute on the CorbaLibPlugin class to resolve a link error ?

My mistake, I didn't put the dlls in a folder named "types" next to the executable.

Re: Corba and pass by reference Method

Quote:
I coincidentally fixed a related issue yesterday in this class, but we probably need an extra unit test to cover/check your case too. One of the problems is that a clone is made during call or send and that the risk is that store is storing to the original, or that the datasources read from the original instead of the new clone. Certainly needs more testing/fixing.

I tried with the last version from Jean's repository which was synchronized with the master from gitorious today, and I have still this issue.

Quote:
Normally not, at least not on Linux. CorbaLibPlugin is used only internally in the orocos-corba transport library. Did you need to set the RTT_CORBA_DLL attribute on the CorbaLibPlugin class to resolve a link error ?

My mistake, I didn't put the dlls in a folder named "types" next to the executable.

--

Mathieu Gautier

Corba and pass by reference Method

Hello,

I'm working with the last version of the repository rtt-mainline-2.0 under windows (There are some symbols missing with win32, Jean Sreng will soon update his repository to fix this).

I have an issue when calling a remote method which take argument by value (see attached file). The value of the argument is lost while building the RemoteMethod object.

I have a method :
&#10;void ReadConstRefStr(const std::string&amp; message)&#10;

I add this method to the operation :
&#10;this-&gt;addOperation(&quot;ReadConstRefStr&quot;, &amp;Test::ReadConstRefStr, this, RTT::OwnThread).arg(&quot;string&quot;, &quot;new message&quot;);&#10;

and I call it from another process :

&#10;RTT::Method&lt;void(const std::string&amp;)&gt; SendConstRefStr = this-&gt;getPeer(this-&gt;getPeerList()[0])-&gt;getOperation(&quot;ReadConstRefStr&quot;);&#10;SendConstRefStr(test); // send to remote user&#10;

The problem lies in the way the reference to the object is handled. When the MethodC is initiliazed (line 318 in RemoteMethod.hpp) it stores a reference to an object which is pointed to by the DataSourceStorage of the RemoteMethod.
But when the RemoteMethod is called, the pointer of DataSourceStorage is changed (call to this->store in RemoteMethodImpl::call_impl in RemoteMethod.hpp) but the arguments of MethodC still point to the old object.

This issue does not happen when an argument is pass by value, since there's only copy (template<class T> class Astore), and no pointer copy (use Astore<T&>).

I have also an another issue in my example I had to declare a new CorbaLibPlugin since this plugin only appear in CorbaLib.cpp and the loader was removed recently (commit 48dcfe758ad305943c58). I may have misunderstood, but I think CorbaLibPlugin must be declared in CorbaLib.hpp.

Regards,
Mathieu