Hi Peter,
I'm getting crash/"double free or corruption" messages in my call
implementation after switching the 'engine' in the last parameter of
TC->operations()->produce() to the *callers* engine instead of the
callee's engine (following your suggestion). The problem occurs only
if the method involves out parameters passed by reference.
Code:
luabind::object call(lua_State *L, TaskContext &tc, const std::string& method,
luabind::object o0, luabind::object o1,
luabind::object o2)
{
base::DataSourceBase::shared_ptr ret;
base::DataSourceBase::shared_ptr arg0, arg1, arg2;
std::vector<base::DataSourceBase::shared_ptr> args;
interface::OperationRepositoryPart *orp = tc.operations()->getPart(method);
TaskContext *our_tc = getTC(L);
// these create appropriate ValueDataSource's on the heap
arg0 = lbo2dsb_type(orp->getArgumentType(1)->getTypeName(), o0);
arg1 = lbo2dsb_type(orp->getArgumentType(2)->getTypeName(), o1);
arg2 = lbo2dsb_type(orp->getArgumentType(3)->getTypeName(), o2);
if(arg0 == NULL || arg1 == NULL || arg2 == NULL)
return luabind::object(L, NULL);
args.push_back(arg0);
args.push_back(arg1);
args.push_back(arg2);
ret = tc.operations()->produce(method, args, our_tc->engine());
// crash/double free in 'ret.get()'
return dsb2lbo(L, ret.get());
}
Any idea? It seems somehow the argument DS get freed too early?
Thanks!
Markus
[PLUMBING] small problem with call/produce and out values
On Fri, Jul 16, 2010 at 3:49 PM, Markus Klotzbuecher
<markus [dot] klotzbuecher [..] ...> wrote:
> Hi Peter,
>
> I'm getting crash/"double free or corruption" messages in my call
> implementation after switching the 'engine' in the last parameter of
> TC->operations()->produce() to the *callers* engine instead of the
> callee's engine (following your suggestion). The problem occurs only
> if the method involves out parameters passed by reference.
>
> Code:
>
> luabind::object call(lua_State *L, TaskContext &tc, const std::string& method,
> luabind::object o0, luabind::object o1,
> luabind::object o2)
> {
> base::DataSourceBase::shared_ptr ret;
> base::DataSourceBase::shared_ptr arg0, arg1, arg2;
> std::vector<base::DataSourceBase::shared_ptr> args;
> interface::OperationRepositoryPart *orp = tc.operations()->getPart(method);
> TaskContext *our_tc = getTC(L);
>
> // these create appropriate ValueDataSource's on the heap
> arg0 = lbo2dsb_type(orp->getArgumentType(1)->getTypeName(), o0);
> arg1 = lbo2dsb_type(orp->getArgumentType(2)->getTypeName(), o1);
> arg2 = lbo2dsb_type(orp->getArgumentType(3)->getTypeName(), o2);
>
> if(arg0 == NULL || arg1 == NULL || arg2 == NULL)
> return luabind::object(L, NULL);
>
> args.push_back(arg0);
> args.push_back(arg1);
> args.push_back(arg2);
>
> ret = tc.operations()->produce(method, args, our_tc->engine());
> // crash/double free in 'ret.get()'
> return dsb2lbo(L, ret.get());
> }
>
> Any idea? It seems somehow the argument DS get freed too early?
It's just the smart pointer impl doing it's work ? Normally the RTT
must store everything as shared_ptr, so it can't go wrong. Doesn't
valgrind tell you where it was first freed ? That could point us to
the bug (in RTT I suppose).
Peter
--
Orocos-Dev mailing list
Orocos-Dev [..] ...
http://lists.mech.kuleuven.be/mailman/listinfo/orocos-dev