Segfault when calling an operation in OwnThread without TSLF initialized

Hello,

I'm not sure this is a bug or I misunderstand something. I have Orocos-RTT
2.3.1 compiled with RT_MALLOC enabled. I have this simple test case:


#include <rtt/TaskContext.hpp>
#include <rtt/Property.hpp>
#include <rtt/Operation.hpp>
#include <rtt/Port.hpp>
#include <rtt/RTT.hpp>

class PingTaskContext : public RTT::TaskContext
{

public:

    void ping() { }

    PingTaskContext(const std::string &name) :
        RTT::TaskContext(name)
    {
        this->addOperation("pingClientThread", &PingTaskContext::ping,
                this, RTT::ClientThread).doc("Ping using the client
thread.");
        this->addOperation("pingOwnThread", &PingTaskContext::ping,
                this, RTT::OwnThread).doc("Ping using the component
thread.");
    }

    virtual ~PingTaskContext() {}

};

int main(int argc, char* argv[])
{
    PingTaskContext ptc("ptc");
    ptc.setActivity(new RTT::Activity(5, 0.01));

    // Test call to pingClientThread through an OperationCaller
    RTT::OperationCaller<void(void)> pingClientThread =
ptc.getOperation("pingClientThread");
    pingClientThread(); // OK

    // Test call to pingOwnThread through an OperationCaller
    RTT::OperationCaller<void(void)> pingOwnThread =
ptc.getOperation("pingOwnThread");
    pingOwnThread(); // SEGFAULT
}


The application generates a segmentation fault when calling pingOwnThread().
Here is the backtrace:


#0  0x00007ffff6edf3c4 in pthread_mutex_lock () from /lib/libpthread.so.0
#1  0x00007ffff6c2f694 in rtos_mutex_lock (size=184) at
/usr/local/src/orocos-toolchain-2.3.1/rtt/rtt/os/tlsf/../gnulinux/fosi.h:237
#2  oro_rt_malloc (size=184) at
/usr/local/src/orocos-toolchain-2.3.1/rtt/rtt/os/tlsf/tlsf.c:631
#3  0x00000000004429b0 in
RTT::os::rt_allocator<boost::detail::sp_counted_impl_pda<RTT::internal::LocalOperationCaller<void
()()>*,
boost::detail::sp_ms_deleter<RTT::internal::LocalOperationCaller<void ()()>
>, RTT::os::rt_allocator<RTT::internal::LocalOperationCaller<void ()()> > >
>::allocate(unsigned long,
boost::detail::sp_counted_impl_pda<RTT::internal::LocalOperationCaller<void
()()>*,
boost::detail::sp_ms_deleter<RTT::internal::LocalOperationCaller<void ()()>
>, RTT::os::rt_allocator<RTT::internal::LocalOperationCaller<void ()()> > >
const*) (this=0x7fffffffdeff, n=1) at
/usr/local/include/rtt/internal/../internal/../os/oro_allocator.hpp:276
#4  0x0000000000441557 in
shared_count<RTT::internal::LocalOperationCaller<void()>*,
boost::detail::sp_ms_deleter<RTT::internal::LocalOperationCaller<void()> >,
RTT::os::rt_allocator<RTT::internal::LocalOperationCaller<void()> > > (
    this=0x7fffffffe0d8, p=0x0, d=..., a=...) at
/usr/include/boost/smart_ptr/detail/shared_count.hpp:159
#5  0x000000000043fee3 in
shared_ptr<RTT::internal::LocalOperationCaller<void()>,
boost::detail::sp_ms_deleter<RTT::internal::LocalOperationCaller<void()> >,
RTT::os::rt_allocator<RTT::internal::LocalOperationCaller<void()> > > (
    this=0x7fffffffe0d0, p=0x0, d=..., a=...) at
/usr/include/boost/smart_ptr/shared_ptr.hpp:205
#6  0x000000000043df36 in
boost::shared_ptr<RTT::internal::LocalOperationCaller<void ()()> >
boost::allocate_shared<RTT::internal::LocalOperationCaller<void ()()>,
RTT::os::rt_allocator<RTT::internal::LocalOperationCaller<void ()()> >,
RTT::internal::LocalOperationCaller<void ()()>
>(RTT::os::rt_allocator<RTT::internal::LocalOperationCaller<void ()()> >
const&, RTT::internal::LocalOperationCaller<void ()()> const&) (a=...,
a1=...)
    at /usr/include/boost/smart_ptr/make_shared.hpp:197
#7  0x000000000043c9d8 in RTT::internal::LocalOperationCaller<void
()()>::cloneRT() const (this=0x6614d0) at
/usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:666
#8  0x000000000043db7d in RTT::internal::LocalOperationCallerImpl<void
()()>::send_impl() (this=0x6614d0) at
/usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:166
#9  0x000000000043dc14 in RTT::internal::LocalOperationCallerImpl<void
()()>::call_impl() (this=0x6614d0) at
/usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:327
#10 0x000000000043c1f0 in RTT::internal::InvokerImpl<0, void ()(),
RTT::internal::LocalOperationCallerImpl<void ()()> >::call() (this=0x6614d0)
at /usr/local/include/rtt/internal/../internal/Invoker.hpp:75
#11 0x00000000004352d0 in RTT::internal::InvokerSignature<0, void ()(),
boost::shared_ptr<RTT::base::OperationCallerBase<void ()()> >
>::operator()() (this=0x7fffffffe348) at
/usr/local/include/rtt/internal/InvokerSignature.hpp:75
#12 0x0000000000433dcb in main (argc=1, argv=0x7fffffffe618) at
/home/hamelinp/devroot/SM/trunk/libs/orocos-utils/test/testSMTaskContext/testSMTaskContext.cpp:144


It crashed in oro_rt_malloc so I initialized the memory pool
(init_memory_pool) and the problem is fixed. Why does calling an operation
in the component thread require to initialize the TSLF memory pool?

Philippe

Segfault when calling an operation in OwnThread without TSLF ini

2011/6/9 Philippe Hamelin <philippe [dot] hamelin [..] ...>

> Hello,
>
> I'm not sure this is a bug or I misunderstand something. I have Orocos-RTT
> 2.3.1 compiled with RT_MALLOC enabled. I have this simple test case:
>
> &#10;&gt; #include &lt;rtt/TaskContext.hpp&gt;&#10;&gt; #include &lt;rtt/Property.hpp&gt;&#10;&gt; #include &lt;rtt/Operation.hpp&gt;&#10;&gt; #include &lt;rtt/Port.hpp&gt;&#10;&gt; #include &lt;rtt/RTT.hpp&gt;&#10;&gt;&#10;&gt; class PingTaskContext : public RTT::TaskContext&#10;&gt; {&#10;&gt;&#10;&gt; public:&#10;&gt;&#10;&gt;     void ping() { }&#10;&gt;&#10;&gt;     PingTaskContext(const std::string &amp;name) :&#10;&gt;         RTT::TaskContext(name)&#10;&gt;     {&#10;&gt;         this-&gt;addOperation(&quot;pingClientThread&quot;, &amp;PingTaskContext::ping,&#10;&gt;                 this, RTT::ClientThread).doc(&quot;Ping using the client&#10;&gt; thread.&quot;);&#10;&gt;         this-&gt;addOperation(&quot;pingOwnThread&quot;, &amp;PingTaskContext::ping,&#10;&gt;                 this, RTT::OwnThread).doc(&quot;Ping using the component&#10;&gt; thread.&quot;);&#10;&gt;     }&#10;&gt;&#10;&gt;     virtual ~PingTaskContext() {}&#10;&gt;&#10;&gt; };&#10;&gt;&#10;&gt; int main(int argc, char* argv[])&#10;&gt; {&#10;&gt;     PingTaskContext ptc(&quot;ptc&quot;);&#10;&gt;     ptc.setActivity(new RTT::Activity(5, 0.01));&#10;&gt;&#10;&gt;     // Test call to pingClientThread through an OperationCaller&#10;&gt;     RTT::OperationCaller&lt;void(void)&gt; pingClientThread =&#10;&gt; ptc.getOperation(&quot;pingClientThread&quot;);&#10;&gt;     pingClientThread(); // OK&#10;&gt;&#10;&gt;     // Test call to pingOwnThread through an OperationCaller&#10;&gt;     RTT::OperationCaller&lt;void(void)&gt; pingOwnThread =&#10;&gt; ptc.getOperation(&quot;pingOwnThread&quot;);&#10;&gt;     pingOwnThread(); // SEGFAULT&#10;&gt; }&#10;&gt;
>
> The application generates a segmentation fault when
> calling pingOwnThread(). Here is the backtrace:
>
> &#10;&gt; #0  0x00007ffff6edf3c4 in pthread_mutex_lock () from /lib/libpthread.so.0&#10;&gt; #1  0x00007ffff6c2f694 in rtos_mutex_lock (size=184) at&#10;&gt; /usr/local/src/orocos-toolchain-2.3.1/rtt/rtt/os/tlsf/../gnulinux/fosi.h:237&#10;&gt; #2  oro_rt_malloc (size=184) at&#10;&gt; /usr/local/src/orocos-toolchain-2.3.1/rtt/rtt/os/tlsf/tlsf.c:631&#10;&gt; #3  0x00000000004429b0 in&#10;&gt; RTT::os::rt_allocator&lt;boost::detail::sp_counted_impl_pda&lt;RTT::internal::LocalOperationCaller&lt;void&#10;&gt; ()()&gt;*,&#10;&gt; boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt;&#10;&gt; &gt;, RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt; &gt;&#10;&gt; &gt;::allocate(unsigned long,&#10;&gt; boost::detail::sp_counted_impl_pda&lt;RTT::internal::LocalOperationCaller&lt;void&#10;&gt; ()()&gt;*,&#10;&gt; boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt;&#10;&gt; &gt;, RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt; &gt;&#10;&gt; const*) (this=0x7fffffffdeff, n=1) at&#10;&gt; /usr/local/include/rtt/internal/../internal/../os/oro_allocator.hpp:276&#10;&gt; #4  0x0000000000441557 in&#10;&gt; shared_count&lt;RTT::internal::LocalOperationCaller&lt;void()&gt;*,&#10;&gt; boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt;,&#10;&gt; RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt; &gt; (&#10;&gt;     this=0x7fffffffe0d8, p=0x0, d=..., a=...) at&#10;&gt; /usr/include/boost/smart_ptr/detail/shared_count.hpp:159&#10;&gt; #5  0x000000000043fee3 in&#10;&gt; shared_ptr&lt;RTT::internal::LocalOperationCaller&lt;void()&gt;,&#10;&gt; boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt;,&#10;&gt; RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt; &gt; (&#10;&gt;     this=0x7fffffffe0d0, p=0x0, d=..., a=...) at&#10;&gt; /usr/include/boost/smart_ptr/shared_ptr.hpp:205&#10;&gt; #6  0x000000000043df36 in&#10;&gt; boost::shared_ptr&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;&#10;&gt; boost::allocate_shared&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt;,&#10;&gt; RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;,&#10;&gt; RTT::internal::LocalOperationCaller&lt;void ()()&gt;&#10;&gt; &gt;(RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;&#10;&gt; const&amp;, RTT::internal::LocalOperationCaller&lt;void ()()&gt; const&amp;) (a=...,&#10;&gt; a1=...)&#10;&gt;     at /usr/include/boost/smart_ptr/make_shared.hpp:197&#10;&gt; #7  0x000000000043c9d8 in RTT::internal::LocalOperationCaller&lt;void&#10;&gt; ()()&gt;::cloneRT() const (this=0x6614d0) at&#10;&gt; /usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:666&#10;&gt; #8  0x000000000043db7d in RTT::internal::LocalOperationCallerImpl&lt;void&#10;&gt; ()()&gt;::send_impl() (this=0x6614d0) at&#10;&gt; /usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:166&#10;&gt; #9  0x000000000043dc14 in RTT::internal::LocalOperationCallerImpl&lt;void&#10;&gt; ()()&gt;::call_impl() (this=0x6614d0) at&#10;&gt; /usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:327&#10;&gt; #10 0x000000000043c1f0 in RTT::internal::InvokerImpl&lt;0, void ()(),&#10;&gt; RTT::internal::LocalOperationCallerImpl&lt;void ()()&gt; &gt;::call() (this=0x6614d0)&#10;&gt; at /usr/local/include/rtt/internal/../internal/Invoker.hpp:75&#10;&gt; #11 0x00000000004352d0 in RTT::internal::InvokerSignature&lt;0, void ()(),&#10;&gt; boost::shared_ptr&lt;RTT::base::OperationCallerBase&lt;void ()()&gt; &gt;&#10;&gt; &gt;::operator()() (this=0x7fffffffe348) at&#10;&gt; /usr/local/include/rtt/internal/InvokerSignature.hpp:75&#10;&gt; #12 0x0000000000433dcb in main (argc=1, argv=0x7fffffffe618) at&#10;&gt; /home/hamelinp/devroot/SM/trunk/libs/orocos-utils/test/testSMTaskContext/testSMTaskContext.cpp:144&#10;&gt;
>
> It crashed in oro_rt_malloc so I initialized the memory pool
> (init_memory_pool) and the problem is fixed. Why does calling an operation
> in the component thread require to initialize the TSLF memory pool?
>
>
>
Ok I found why this is happening. The cloneRT() method, which seems to be
used for OperationCaller, makes use of the rt_allocator :

&#10;typename LocalOperationCallerImpl&lt;Signature&gt;::shared_ptr cloneRT() const&#10;{&#10;    //void* obj =&#10;oro_rt_malloc(sizeof(LocalOperationCallerImpl&lt;Signature&gt;));&#10;    //return new(obj) LocalOperationCaller&lt;Signature&gt;(*this);&#10;    return boost::allocate_shared&lt;LocalOperationCaller&lt;Signature&gt;&#10;&gt;(os::rt_allocator&lt;LocalOperationCaller&lt;Signature&gt; &gt;(), *this);&#10;}&#10;

So that means that if Orocos-RTT is compiled with RT_MALLOC support one
should always initialize the memory pool before doing anything. I thought
wrongly that TLSF was only used for real-time logging. This leads me to ask
some questions:

1. Is this documented somewhere?
2. Does ORO_main should do some default initialization (letting the user to
resize it afterwhile) of the memory pool if no parameters are given on the
command line?
3. Shouldn't we put a big assert in the rt_malloc if no memory pool is
initialized?
4. Is there a define that tell me that TSLF is enabled in RTT such that I
need to initialize the memory pool?

Philippe

Segfault when calling an operation in OwnThread without TSLF ini

On Thu, Jun 9, 2011 at 5:34 PM, Philippe Hamelin
<philippe [dot] hamelin [..] ...> wrote:
...
> 2011/6/9 Philippe Hamelin <philippe [dot] hamelin [..] ...>
>> It crashed in oro_rt_malloc so I initialized the memory pool
>> (init_memory_pool) and the problem is fixed. Why does calling an operation
>> in the component thread require to initialize the TSLF memory pool?
>>
>
> Ok I found why this is happening. The cloneRT() method, which seems to be
> used for OperationCaller, makes use of the rt_allocator :
> &#10;&gt; typename LocalOperationCallerImpl&lt;Signature&gt;::shared_ptr cloneRT() const&#10;&gt; {&#10;&gt;     //void* obj =&#10;&gt; oro_rt_malloc(sizeof(LocalOperationCallerImpl&lt;Signature&gt;));&#10;&gt;     //return new(obj) LocalOperationCaller&lt;Signature&gt;(*this);&#10;&gt;     return boost::allocate_shared&lt;LocalOperationCaller&lt;Signature&gt;&#10;&gt;&gt;(os::rt_allocator&lt;LocalOperationCaller&lt;Signature&gt; &gt;(), *this);&#10;&gt; }&#10;&gt;
> So that means that if Orocos-RTT is compiled with RT_MALLOC support one
> should always initialize the memory pool before doing anything. I thought
> wrongly that TLSF was only used for real-time logging. This leads me to ask
> some questions:
> 1. Is this documented somewhere?

It's enabled when using the deployers and can be configured using a command
line option. It's not documented...

> 2. Does ORO_main should do some default initialization (letting the user to
> resize it afterwhile) of the memory pool if no parameters are given on the
> command line?

That code in the deployer could move to ORO_main... but it's some work since
we also want to have the options show up when the program is run with
--help, ie, using boost::program_options

> 3. Shouldn't we put a big assert in the rt_malloc if no memory pool is
> initialized?

It should at least return NULL and not crash. We should log an error when no
initialisation has been done, since this is in most cases a user bug.

> 4. Is there a define that tell me that TSLF is enabled in RTT such that I
> need to initialize the memory pool?

See OCL's deployer.cpp for the logic we use...

> Philippe
>
>

Peter
--
Orocos-Dev mailing list
Orocos-Dev [..] ...
http://lists.mech.kuleuven.be/mailman/listinfo/orocos-dev

Segfault when calling an operation in OwnThread without TSLF ini

2011/6/9 Philippe Hamelin <philippe [dot] hamelin [..] ...>

> 2011/6/9 Philippe Hamelin <philippe [dot] hamelin [..] ...>
>
>> Hello,
>>
>> I'm not sure this is a bug or I misunderstand something. I have Orocos-RTT
>> 2.3.1 compiled with RT_MALLOC enabled. I have this simple test case:
>>
>> &#10;&gt;&gt; #include &lt;rtt/TaskContext.hpp&gt;&#10;&gt;&gt; #include &lt;rtt/Property.hpp&gt;&#10;&gt;&gt; #include &lt;rtt/Operation.hpp&gt;&#10;&gt;&gt; #include &lt;rtt/Port.hpp&gt;&#10;&gt;&gt; #include &lt;rtt/RTT.hpp&gt;&#10;&gt;&gt;&#10;&gt;&gt; class PingTaskContext : public RTT::TaskContext&#10;&gt;&gt; {&#10;&gt;&gt;&#10;&gt;&gt; public:&#10;&gt;&gt;&#10;&gt;&gt;     void ping() { }&#10;&gt;&gt;&#10;&gt;&gt;     PingTaskContext(const std::string &amp;name) :&#10;&gt;&gt;         RTT::TaskContext(name)&#10;&gt;&gt;     {&#10;&gt;&gt;         this-&gt;addOperation(&quot;pingClientThread&quot;, &amp;PingTaskContext::ping,&#10;&gt;&gt;                 this, RTT::ClientThread).doc(&quot;Ping using the client&#10;&gt;&gt; thread.&quot;);&#10;&gt;&gt;         this-&gt;addOperation(&quot;pingOwnThread&quot;, &amp;PingTaskContext::ping,&#10;&gt;&gt;                 this, RTT::OwnThread).doc(&quot;Ping using the component&#10;&gt;&gt; thread.&quot;);&#10;&gt;&gt;     }&#10;&gt;&gt;&#10;&gt;&gt;     virtual ~PingTaskContext() {}&#10;&gt;&gt;&#10;&gt;&gt; };&#10;&gt;&gt;&#10;&gt;&gt; int main(int argc, char* argv[])&#10;&gt;&gt; {&#10;&gt;&gt;     PingTaskContext ptc(&quot;ptc&quot;);&#10;&gt;&gt;     ptc.setActivity(new RTT::Activity(5, 0.01));&#10;&gt;&gt;&#10;&gt;&gt;     // Test call to pingClientThread through an OperationCaller&#10;&gt;&gt;     RTT::OperationCaller&lt;void(void)&gt; pingClientThread =&#10;&gt;&gt; ptc.getOperation(&quot;pingClientThread&quot;);&#10;&gt;&gt;     pingClientThread(); // OK&#10;&gt;&gt;&#10;&gt;&gt;     // Test call to pingOwnThread through an OperationCaller&#10;&gt;&gt;     RTT::OperationCaller&lt;void(void)&gt; pingOwnThread =&#10;&gt;&gt; ptc.getOperation(&quot;pingOwnThread&quot;);&#10;&gt;&gt;     pingOwnThread(); // SEGFAULT&#10;&gt;&gt; }&#10;&gt;&gt;
>>
>> The application generates a segmentation fault when
>> calling pingOwnThread(). Here is the backtrace:
>>
>> &#10;&gt;&gt; #0  0x00007ffff6edf3c4 in pthread_mutex_lock () from /lib/libpthread.so.0&#10;&gt;&gt; #1  0x00007ffff6c2f694 in rtos_mutex_lock (size=184) at&#10;&gt;&gt; /usr/local/src/orocos-toolchain-2.3.1/rtt/rtt/os/tlsf/../gnulinux/fosi.h:237&#10;&gt;&gt; #2  oro_rt_malloc (size=184) at&#10;&gt;&gt; /usr/local/src/orocos-toolchain-2.3.1/rtt/rtt/os/tlsf/tlsf.c:631&#10;&gt;&gt; #3  0x00000000004429b0 in&#10;&gt;&gt; RTT::os::rt_allocator&lt;boost::detail::sp_counted_impl_pda&lt;RTT::internal::LocalOperationCaller&lt;void&#10;&gt;&gt; ()()&gt;*,&#10;&gt;&gt; boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt;&#10;&gt;&gt; &gt;, RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt; &gt;&#10;&gt;&gt; &gt;::allocate(unsigned long,&#10;&gt;&gt; boost::detail::sp_counted_impl_pda&lt;RTT::internal::LocalOperationCaller&lt;void&#10;&gt;&gt; ()()&gt;*,&#10;&gt;&gt; boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt;&#10;&gt;&gt; &gt;, RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt; &gt;&#10;&gt;&gt; const*) (this=0x7fffffffdeff, n=1) at&#10;&gt;&gt; /usr/local/include/rtt/internal/../internal/../os/oro_allocator.hpp:276&#10;&gt;&gt; #4  0x0000000000441557 in&#10;&gt;&gt; shared_count&lt;RTT::internal::LocalOperationCaller&lt;void()&gt;*,&#10;&gt;&gt; boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt;,&#10;&gt;&gt; RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt; &gt; (&#10;&gt;&gt;     this=0x7fffffffe0d8, p=0x0, d=..., a=...) at&#10;&gt;&gt; /usr/include/boost/smart_ptr/detail/shared_count.hpp:159&#10;&gt;&gt; #5  0x000000000043fee3 in&#10;&gt;&gt; shared_ptr&lt;RTT::internal::LocalOperationCaller&lt;void()&gt;,&#10;&gt;&gt; boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt;,&#10;&gt;&gt; RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt; &gt; (&#10;&gt;&gt;     this=0x7fffffffe0d0, p=0x0, d=..., a=...) at&#10;&gt;&gt; /usr/include/boost/smart_ptr/shared_ptr.hpp:205&#10;&gt;&gt; #6  0x000000000043df36 in&#10;&gt;&gt; boost::shared_ptr&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;&#10;&gt;&gt; boost::allocate_shared&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt;,&#10;&gt;&gt; RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;,&#10;&gt;&gt; RTT::internal::LocalOperationCaller&lt;void ()()&gt;&#10;&gt;&gt; &gt;(RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;&#10;&gt;&gt; const&amp;, RTT::internal::LocalOperationCaller&lt;void ()()&gt; const&amp;) (a=...,&#10;&gt;&gt; a1=...)&#10;&gt;&gt;     at /usr/include/boost/smart_ptr/make_shared.hpp:197&#10;&gt;&gt; #7  0x000000000043c9d8 in RTT::internal::LocalOperationCaller&lt;void&#10;&gt;&gt; ()()&gt;::cloneRT() const (this=0x6614d0) at&#10;&gt;&gt; /usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:666&#10;&gt;&gt; #8  0x000000000043db7d in RTT::internal::LocalOperationCallerImpl&lt;void&#10;&gt;&gt; ()()&gt;::send_impl() (this=0x6614d0) at&#10;&gt;&gt; /usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:166&#10;&gt;&gt; #9  0x000000000043dc14 in RTT::internal::LocalOperationCallerImpl&lt;void&#10;&gt;&gt; ()()&gt;::call_impl() (this=0x6614d0) at&#10;&gt;&gt; /usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:327&#10;&gt;&gt; #10 0x000000000043c1f0 in RTT::internal::InvokerImpl&lt;0, void ()(),&#10;&gt;&gt; RTT::internal::LocalOperationCallerImpl&lt;void ()()&gt; &gt;::call() (this=0x6614d0)&#10;&gt;&gt; at /usr/local/include/rtt/internal/../internal/Invoker.hpp:75&#10;&gt;&gt; #11 0x00000000004352d0 in RTT::internal::InvokerSignature&lt;0, void ()(),&#10;&gt;&gt; boost::shared_ptr&lt;RTT::base::OperationCallerBase&lt;void ()()&gt; &gt;&#10;&gt;&gt; &gt;::operator()() (this=0x7fffffffe348) at&#10;&gt;&gt; /usr/local/include/rtt/internal/InvokerSignature.hpp:75&#10;&gt;&gt; #12 0x0000000000433dcb in main (argc=1, argv=0x7fffffffe618) at&#10;&gt;&gt; /home/hamelinp/devroot/SM/trunk/libs/orocos-utils/test/testSMTaskContext/testSMTaskContext.cpp:144&#10;&gt;&gt;
>>
>> It crashed in oro_rt_malloc so I initialized the memory pool
>> (init_memory_pool) and the problem is fixed. Why does calling an operation
>> in the component thread require to initialize the TSLF memory pool?
>>
>>
>>
> Ok I found why this is happening. The cloneRT() method, which seems to be
> used for OperationCaller, makes use of the rt_allocator :
>
> &#10;&gt; typename LocalOperationCallerImpl&lt;Signature&gt;::shared_ptr cloneRT() const&#10;&gt; {&#10;&gt;     //void* obj =&#10;&gt; oro_rt_malloc(sizeof(LocalOperationCallerImpl&lt;Signature&gt;));&#10;&gt;     //return new(obj) LocalOperationCaller&lt;Signature&gt;(*this);&#10;&gt;     return boost::allocate_shared&lt;LocalOperationCaller&lt;Signature&gt;&#10;&gt; &gt;(os::rt_allocator&lt;LocalOperationCaller&lt;Signature&gt; &gt;(), *this);&#10;&gt; }&#10;&gt;
>
> So that means that if Orocos-RTT is compiled with RT_MALLOC support one
> should always initialize the memory pool before doing anything. I thought
> wrongly that TLSF was only used for real-time logging. This leads me to ask
> some questions:
>
> 1. Is this documented somewhere?
> 2. Does ORO_main should do some default initialization (letting the user to
> resize it afterwhile) of the memory pool if no parameters are given on the
> command line?
> 3. Shouldn't we put a big assert in the rt_malloc if no memory pool is
> initialized?
> 4. Is there a define that tell me that TSLF is enabled in RTT such that I
> need to initialize the memory pool?
>
>
#4 is answered. I found that there's a define available through
rtt-config.h, which is OS_RT_MALLOC.

Philippe

Segfault when calling an operation in OwnThread without TSLF ini

On Jun 9, 2011, at 13:02 , Philippe Hamelin wrote:

> 2011/6/9 Philippe Hamelin <philippe [dot] hamelin [..] ...>
> 2011/6/9 Philippe Hamelin <philippe [dot] hamelin [..] ...>
> Hello,
>
> I'm not sure this is a bug or I misunderstand something. I have Orocos-RTT 2.3.1 compiled with RT_MALLOC enabled. I have this simple test case:
>
> &#10;&gt; #include &lt;rtt/TaskContext.hpp&gt;&#10;&gt; #include &lt;rtt/Property.hpp&gt;&#10;&gt; #include &lt;rtt/Operation.hpp&gt;&#10;&gt; #include &lt;rtt/Port.hpp&gt;&#10;&gt; #include &lt;rtt/RTT.hpp&gt;&#10;&gt; &#10;&gt; class PingTaskContext : public RTT::TaskContext&#10;&gt; {&#10;&gt; &#10;&gt; public:&#10;&gt; &#10;&gt;     void ping() { }&#10;&gt; &#10;&gt;     PingTaskContext(const std::string &amp;name) :&#10;&gt;         RTT::TaskContext(name)&#10;&gt;     {&#10;&gt;         this-&gt;addOperation(&quot;pingClientThread&quot;, &amp;PingTaskContext::ping,&#10;&gt;                 this, RTT::ClientThread).doc(&quot;Ping using the client thread.&quot;);&#10;&gt;         this-&gt;addOperation(&quot;pingOwnThread&quot;, &amp;PingTaskContext::ping,&#10;&gt;                 this, RTT::OwnThread).doc(&quot;Ping using the component thread.&quot;);&#10;&gt;     }&#10;&gt; &#10;&gt;     virtual ~PingTaskContext() {}&#10;&gt; &#10;&gt; };&#10;&gt; &#10;&gt; int main(int argc, char* argv[])&#10;&gt; {&#10;&gt;     PingTaskContext ptc(&quot;ptc&quot;);&#10;&gt;     ptc.setActivity(new RTT::Activity(5, 0.01));&#10;&gt; &#10;&gt;     // Test call to pingClientThread through an OperationCaller&#10;&gt;     RTT::OperationCaller&lt;void(void)&gt; pingClientThread = ptc.getOperation(&quot;pingClientThread&quot;);&#10;&gt;     pingClientThread(); // OK&#10;&gt; &#10;&gt;     // Test call to pingOwnThread through an OperationCaller&#10;&gt;     RTT::OperationCaller&lt;void(void)&gt; pingOwnThread = ptc.getOperation(&quot;pingOwnThread&quot;);&#10;&gt;     pingOwnThread(); // SEGFAULT&#10;&gt; }&#10;&gt;
>
> The application generates a segmentation fault when calling pingOwnThread(). Here is the backtrace:
>
> &#10;&gt; #0  0x00007ffff6edf3c4 in pthread_mutex_lock () from /lib/libpthread.so.0&#10;&gt; #1  0x00007ffff6c2f694 in rtos_mutex_lock (size=184) at /usr/local/src/orocos-toolchain-2.3.1/rtt/rtt/os/tlsf/../gnulinux/fosi.h:237&#10;&gt; #2  oro_rt_malloc (size=184) at /usr/local/src/orocos-toolchain-2.3.1/rtt/rtt/os/tlsf/tlsf.c:631&#10;&gt; #3  0x00000000004429b0 in RTT::os::rt_allocator&lt;boost::detail::sp_counted_impl_pda&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt;*, boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;, RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt; &gt; &gt;::allocate(unsigned long, boost::detail::sp_counted_impl_pda&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt;*, boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;, RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt; &gt; const*) (this=0x7fffffffdeff, n=1) at /usr/local/include/rtt/internal/../internal/../os/oro_allocator.hpp:276&#10;&gt; #4  0x0000000000441557 in shared_count&lt;RTT::internal::LocalOperationCaller&lt;void()&gt;*, boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt;, RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt; &gt; (&#10;&gt;     this=0x7fffffffe0d8, p=0x0, d=..., a=...) at /usr/include/boost/smart_ptr/detail/shared_count.hpp:159&#10;&gt; #5  0x000000000043fee3 in shared_ptr&lt;RTT::internal::LocalOperationCaller&lt;void()&gt;, boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt;, RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt; &gt; (&#10;&gt;     this=0x7fffffffe0d0, p=0x0, d=..., a=...) at /usr/include/boost/smart_ptr/shared_ptr.hpp:205&#10;&gt; #6  0x000000000043df36 in boost::shared_ptr&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt; boost::allocate_shared&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt;, RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;, RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;(RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt; const&amp;, RTT::internal::LocalOperationCaller&lt;void ()()&gt; const&amp;) (a=..., a1=...)&#10;&gt;     at /usr/include/boost/smart_ptr/make_shared.hpp:197&#10;&gt; #7  0x000000000043c9d8 in RTT::internal::LocalOperationCaller&lt;void ()()&gt;::cloneRT() const (this=0x6614d0) at /usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:666&#10;&gt; #8  0x000000000043db7d in RTT::internal::LocalOperationCallerImpl&lt;void ()()&gt;::send_impl() (this=0x6614d0) at /usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:166&#10;&gt; #9  0x000000000043dc14 in RTT::internal::LocalOperationCallerImpl&lt;void ()()&gt;::call_impl() (this=0x6614d0) at /usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:327&#10;&gt; #10 0x000000000043c1f0 in RTT::internal::InvokerImpl&lt;0, void ()(), RTT::internal::LocalOperationCallerImpl&lt;void ()()&gt; &gt;::call() (this=0x6614d0) at /usr/local/include/rtt/internal/../internal/Invoker.hpp:75&#10;&gt; #11 0x00000000004352d0 in RTT::internal::InvokerSignature&lt;0, void ()(), boost::shared_ptr&lt;RTT::base::OperationCallerBase&lt;void ()()&gt; &gt; &gt;::operator()() (this=0x7fffffffe348) at /usr/local/include/rtt/internal/InvokerSignature.hpp:75&#10;&gt; #12 0x0000000000433dcb in main (argc=1, argv=0x7fffffffe618) at /home/hamelinp/devroot/SM/trunk/libs/orocos-utils/test/testSMTaskContext/testSMTaskContext.cpp:144&#10;&gt;
>
> It crashed in oro_rt_malloc so I initialized the memory pool (init_memory_pool) and the problem is fixed. Why does calling an operation in the component thread require to initialize the TSLF memory pool?
>
>
>
> Ok I found why this is happening. The cloneRT() method, which seems to be used for OperationCaller, makes use of the rt_allocator :
>
> &#10;&gt; typename LocalOperationCallerImpl&lt;Signature&gt;::shared_ptr cloneRT() const&#10;&gt; {&#10;&gt;     //void* obj = oro_rt_malloc(sizeof(LocalOperationCallerImpl&lt;Signature&gt;));&#10;&gt;     //return new(obj) LocalOperationCaller&lt;Signature&gt;(*this);&#10;&gt;     return boost::allocate_shared&lt;LocalOperationCaller&lt;Signature&gt; &gt;(os::rt_allocator&lt;LocalOperationCaller&lt;Signature&gt; &gt;(), *this);&#10;&gt; }&#10;&gt;
>
> So that means that if Orocos-RTT is compiled with RT_MALLOC support one should always initialize the memory pool before doing anything. I thought wrongly that TLSF was only used for real-time logging. This leads me to ask some questions:

This is actually news to me ... but it doesn't surprise me.

> 1. Is this documented somewhere?

AFAIK the only documentation related to TLSF (and real-time logging) is the logging page I created on the wiki ...?

> 2. Does ORO_main should do some default initialization (letting the user to resize it afterwhile) of the memory pool if no parameters are given on the command line?

Yes it should, same as with the OCL deployer (or in reality, the deployer TLSF init code should go _in_ RTT)? That uses a cmake-time constant for the default memory pool size, which the user can obviously override.

> 3. Shouldn't we put a big assert in the rt_malloc if no memory pool is initialized?

If it _truly is_ a requirement for RTT, then something should occur to warn the user. Or do the above?

> 4. Is there a define that tell me that TSLF is enabled in RTT such that I need to initialize the memory pool?
>
>
> #4 is answered. I found that there's a define available through rtt-config.h, which is OS_RT_MALLOC.

What I'm getting from this is that few people out there are actually using TLSF and/or the real-time logging in RTT?

Sorry that is happening to you Philippe, it's just that we've been using TLSF and the real-time logging for so long based on a customized RTT/OCL v1, that we simply don't have any experience using it with v2. And we've also laxed in providing examples of how to do it ... :-(
S

Segfault when calling an operation in OwnThread without TSLF ini

2011/6/9 S Roderick <kiwi [dot] net [..] ...>

> On Jun 9, 2011, at 13:02 , Philippe Hamelin wrote:
>
> > 2011/6/9 Philippe Hamelin <philippe [dot] hamelin [..] ...>
> > 2011/6/9 Philippe Hamelin <philippe [dot] hamelin [..] ...>
> > Hello,
> >
> > I'm not sure this is a bug or I misunderstand something. I have
> Orocos-RTT 2.3.1 compiled with RT_MALLOC enabled. I have this simple test
> case:
> >
> > &#10;&gt; &gt; #include &lt;rtt/TaskContext.hpp&gt;&#10;&gt; &gt; #include &lt;rtt/Property.hpp&gt;&#10;&gt; &gt; #include &lt;rtt/Operation.hpp&gt;&#10;&gt; &gt; #include &lt;rtt/Port.hpp&gt;&#10;&gt; &gt; #include &lt;rtt/RTT.hpp&gt;&#10;&gt; &gt;&#10;&gt; &gt; class PingTaskContext : public RTT::TaskContext&#10;&gt; &gt; {&#10;&gt; &gt;&#10;&gt; &gt; public:&#10;&gt; &gt;&#10;&gt; &gt;     void ping() { }&#10;&gt; &gt;&#10;&gt; &gt;     PingTaskContext(const std::string &amp;name) :&#10;&gt; &gt;         RTT::TaskContext(name)&#10;&gt; &gt;     {&#10;&gt; &gt;         this-&gt;addOperation(&quot;pingClientThread&quot;, &amp;PingTaskContext::ping,&#10;&gt; &gt;                 this, RTT::ClientThread).doc(&quot;Ping using the client&#10;&gt; thread.&quot;);&#10;&gt; &gt;         this-&gt;addOperation(&quot;pingOwnThread&quot;, &amp;PingTaskContext::ping,&#10;&gt; &gt;                 this, RTT::OwnThread).doc(&quot;Ping using the component&#10;&gt; thread.&quot;);&#10;&gt; &gt;     }&#10;&gt; &gt;&#10;&gt; &gt;     virtual ~PingTaskContext() {}&#10;&gt; &gt;&#10;&gt; &gt; };&#10;&gt; &gt;&#10;&gt; &gt; int main(int argc, char* argv[])&#10;&gt; &gt; {&#10;&gt; &gt;     PingTaskContext ptc(&quot;ptc&quot;);&#10;&gt; &gt;     ptc.setActivity(new RTT::Activity(5, 0.01));&#10;&gt; &gt;&#10;&gt; &gt;     // Test call to pingClientThread through an OperationCaller&#10;&gt; &gt;     RTT::OperationCaller&lt;void(void)&gt; pingClientThread =&#10;&gt; ptc.getOperation(&quot;pingClientThread&quot;);&#10;&gt; &gt;     pingClientThread(); // OK&#10;&gt; &gt;&#10;&gt; &gt;     // Test call to pingOwnThread through an OperationCaller&#10;&gt; &gt;     RTT::OperationCaller&lt;void(void)&gt; pingOwnThread =&#10;&gt; ptc.getOperation(&quot;pingOwnThread&quot;);&#10;&gt; &gt;     pingOwnThread(); // SEGFAULT&#10;&gt; &gt; }&#10;&gt; &gt;
> >
> > The application generates a segmentation fault when calling
> pingOwnThread(). Here is the backtrace:
> >
> > &#10;&gt; &gt; #0  0x00007ffff6edf3c4 in pthread_mutex_lock () from /lib/libpthread.so.0&#10;&gt; &gt; #1  0x00007ffff6c2f694 in rtos_mutex_lock (size=184) at&#10;&gt; /usr/local/src/orocos-toolchain-2.3.1/rtt/rtt/os/tlsf/../gnulinux/fosi.h:237&#10;&gt; &gt; #2  oro_rt_malloc (size=184) at&#10;&gt; /usr/local/src/orocos-toolchain-2.3.1/rtt/rtt/os/tlsf/tlsf.c:631&#10;&gt; &gt; #3  0x00000000004429b0 in&#10;&gt; RTT::os::rt_allocator&lt;boost::detail::sp_counted_impl_pda&lt;RTT::internal::LocalOperationCaller&lt;void&#10;&gt; ()()&gt;*,&#10;&gt; boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt;&#10;&gt; &gt;, RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt; &gt;&#10;&gt; &gt;::allocate(unsigned long,&#10;&gt; boost::detail::sp_counted_impl_pda&lt;RTT::internal::LocalOperationCaller&lt;void&#10;&gt; ()()&gt;*,&#10;&gt; boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt;&#10;&gt; &gt;, RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt; &gt;&#10;&gt; const*) (this=0x7fffffffdeff, n=1) at&#10;&gt; /usr/local/include/rtt/internal/../internal/../os/oro_allocator.hpp:276&#10;&gt; &gt; #4  0x0000000000441557 in&#10;&gt; shared_count&lt;RTT::internal::LocalOperationCaller&lt;void()&gt;*,&#10;&gt; boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt;,&#10;&gt; RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt; &gt; (&#10;&gt; &gt;     this=0x7fffffffe0d8, p=0x0, d=..., a=...) at&#10;&gt; /usr/include/boost/smart_ptr/detail/shared_count.hpp:159&#10;&gt; &gt; #5  0x000000000043fee3 in&#10;&gt; shared_ptr&lt;RTT::internal::LocalOperationCaller&lt;void()&gt;,&#10;&gt; boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt;,&#10;&gt; RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt; &gt; (&#10;&gt; &gt;     this=0x7fffffffe0d0, p=0x0, d=..., a=...) at&#10;&gt; /usr/include/boost/smart_ptr/shared_ptr.hpp:205&#10;&gt; &gt; #6  0x000000000043df36 in&#10;&gt; boost::shared_ptr&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;&#10;&gt; boost::allocate_shared&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt;,&#10;&gt; RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;,&#10;&gt; RTT::internal::LocalOperationCaller&lt;void ()()&gt;&#10;&gt; &gt;(RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;&#10;&gt; const&amp;, RTT::internal::LocalOperationCaller&lt;void ()()&gt; const&amp;) (a=...,&#10;&gt; a1=...)&#10;&gt; &gt;     at /usr/include/boost/smart_ptr/make_shared.hpp:197&#10;&gt; &gt; #7  0x000000000043c9d8 in RTT::internal::LocalOperationCaller&lt;void&#10;&gt; ()()&gt;::cloneRT() const (this=0x6614d0) at&#10;&gt; /usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:666&#10;&gt; &gt; #8  0x000000000043db7d in RTT::internal::LocalOperationCallerImpl&lt;void&#10;&gt; ()()&gt;::send_impl() (this=0x6614d0) at&#10;&gt; /usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:166&#10;&gt; &gt; #9  0x000000000043dc14 in RTT::internal::LocalOperationCallerImpl&lt;void&#10;&gt; ()()&gt;::call_impl() (this=0x6614d0) at&#10;&gt; /usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:327&#10;&gt; &gt; #10 0x000000000043c1f0 in RTT::internal::InvokerImpl&lt;0, void ()(),&#10;&gt; RTT::internal::LocalOperationCallerImpl&lt;void ()()&gt; &gt;::call() (this=0x6614d0)&#10;&gt; at /usr/local/include/rtt/internal/../internal/Invoker.hpp:75&#10;&gt; &gt; #11 0x00000000004352d0 in RTT::internal::InvokerSignature&lt;0, void ()(),&#10;&gt; boost::shared_ptr&lt;RTT::base::OperationCallerBase&lt;void ()()&gt; &gt;&#10;&gt; &gt;::operator()() (this=0x7fffffffe348) at&#10;&gt; /usr/local/include/rtt/internal/InvokerSignature.hpp:75&#10;&gt; &gt; #12 0x0000000000433dcb in main (argc=1, argv=0x7fffffffe618) at&#10;&gt; /home/hamelinp/devroot/SM/trunk/libs/orocos-utils/test/testSMTaskContext/testSMTaskContext.cpp:144&#10;&gt; &gt;
> >
> > It crashed in oro_rt_malloc so I initialized the memory pool
> (init_memory_pool) and the problem is fixed. Why does calling an operation
> in the component thread require to initialize the TSLF memory pool?
> >
> >
> >
> > Ok I found why this is happening. The cloneRT() method, which seems to be
> used for OperationCaller, makes use of the rt_allocator :
> >
> > &#10;&gt; &gt; typename LocalOperationCallerImpl&lt;Signature&gt;::shared_ptr cloneRT() const&#10;&gt; &gt; {&#10;&gt; &gt;     //void* obj =&#10;&gt; oro_rt_malloc(sizeof(LocalOperationCallerImpl&lt;Signature&gt;));&#10;&gt; &gt;     //return new(obj) LocalOperationCaller&lt;Signature&gt;(*this);&#10;&gt; &gt;     return boost::allocate_shared&lt;LocalOperationCaller&lt;Signature&gt;&#10;&gt; &gt;(os::rt_allocator&lt;LocalOperationCaller&lt;Signature&gt; &gt;(), *this);&#10;&gt; &gt; }&#10;&gt; &gt;
> >
> > So that means that if Orocos-RTT is compiled with RT_MALLOC support one
> should always initialize the memory pool before doing anything. I thought
> wrongly that TLSF was only used for real-time logging. This leads me to ask
> some questions:
>
> This is actually news to me ... but it doesn't surprise me.
>
> > 1. Is this documented somewhere?
>
> AFAIK the only documentation related to TLSF (and real-time logging) is the
> logging page I created on the wiki ...?
>
> > 2. Does ORO_main should do some default initialization (letting the user
> to resize it afterwhile) of the memory pool if no parameters are given on
> the command line?
>
> Yes it should, same as with the OCL deployer (or in reality, the deployer
> TLSF init code should go _in_ RTT)? That uses a cmake-time constant for the
> default memory pool size, which the user can obviously override.
>
> > 3. Shouldn't we put a big assert in the rt_malloc if no memory pool is
> initialized?
>
> If it _truly is_ a requirement for RTT, then something should occur to warn
> the user. Or do the above?
>
> > 4. Is there a define that tell me that TSLF is enabled in RTT such that I
> need to initialize the memory pool?
> >
> >
> > #4 is answered. I found that there's a define available through
> rtt-config.h, which is OS_RT_MALLOC.
>
> What I'm getting from this is that few people out there are actually using
> TLSF and/or the real-time logging in RTT?
>
> Sorry that is happening to you Philippe, it's just that we've been using
> TLSF and the real-time logging for so long based on a customized RTT/OCL v1,
> that we simply don't have any experience using it with v2. And we've also
> laxed in providing examples of how to do it ... :-(
>

We are using TLSF + real-time logging for some months in v2.x, but I've
never faced the problem of having an OperationCaller + no TSLF initialized
since today.

Philippe

Segfault when calling an operation in OwnThread without TSLF ini

On Thu, Jun 9, 2011 at 5:07 PM, Philippe Hamelin <philippe [dot] hamelin [..] ...
> wrote:

> Hello,
>
> I'm not sure this is a bug or I misunderstand something. I have Orocos-RTT
> 2.3.1 compiled with RT_MALLOC enabled. I have this simple test case:
>
> &#10;&gt; #include &lt;rtt/TaskContext.hpp&gt;&#10;&gt; #include &lt;rtt/Property.hpp&gt;&#10;&gt; #include &lt;rtt/Operation.hpp&gt;&#10;&gt; #include &lt;rtt/Port.hpp&gt;&#10;&gt; #include &lt;rtt/RTT.hpp&gt;&#10;&gt;&#10;&gt; class PingTaskContext : public RTT::TaskContext&#10;&gt; {&#10;&gt;&#10;&gt; public:&#10;&gt;&#10;&gt;     void ping() { }&#10;&gt;&#10;&gt;     PingTaskContext(const std::string &amp;name) :&#10;&gt;         RTT::TaskContext(name)&#10;&gt;     {&#10;&gt;         this-&gt;addOperation(&quot;pingClientThread&quot;, &amp;PingTaskContext::ping,&#10;&gt;                 this, RTT::ClientThread).doc(&quot;Ping using the client&#10;&gt; thread.&quot;);&#10;&gt;         this-&gt;addOperation(&quot;pingOwnThread&quot;, &amp;PingTaskContext::ping,&#10;&gt;                 this, RTT::OwnThread).doc(&quot;Ping using the component&#10;&gt; thread.&quot;);&#10;&gt;     }&#10;&gt;&#10;&gt;     virtual ~PingTaskContext() {}&#10;&gt;&#10;&gt; };&#10;&gt;&#10;&gt; int main(int argc, char* argv[])&#10;&gt; {&#10;&gt;     PingTaskContext ptc(&quot;ptc&quot;);&#10;&gt;     ptc.setActivity(new RTT::Activity(5, 0.01));&#10;&gt;&#10;&gt;     // Test call to pingClientThread through an OperationCaller&#10;&gt;     RTT::OperationCaller&lt;void(void)&gt; pingClientThread =&#10;&gt; ptc.getOperation(&quot;pingClientThread&quot;);&#10;&gt;     pingClientThread(); // OK&#10;&gt;&#10;&gt;     // Test call to pingOwnThread through an OperationCaller&#10;&gt;     RTT::OperationCaller&lt;void(void)&gt; pingOwnThread =&#10;&gt; ptc.getOperation(&quot;pingOwnThread&quot;);&#10;&gt;     pingOwnThread(); // SEGFAULT&#10;&gt; }&#10;&gt;&#10;&#10;A shot in the dark: Try using ORO_MAIN instead of the regular main function.&#10;It wouldn&#039;t surprise me that ORO_MAIN performs some TLSF initialization code&#10;(set the memory pool?). If ORO_MAIN is not an option, verify whether you&#10;should be doing some explicit TLSF configuration before using it. What do&#10;the experts have to say here, Stephen?, Peter?.&#10;&#10;Adolfo.&#10;&#10;
>
> The application generates a segmentation fault when
> calling pingOwnThread(). Here is the backtrace:
>
> &#10;&gt; #0  0x00007ffff6edf3c4 in pthread_mutex_lock () from /lib/libpthread.so.0&#10;&gt; #1  0x00007ffff6c2f694 in rtos_mutex_lock (size=184) at&#10;&gt; /usr/local/src/orocos-toolchain-2.3.1/rtt/rtt/os/tlsf/../gnulinux/fosi.h:237&#10;&gt; #2  oro_rt_malloc (size=184) at&#10;&gt; /usr/local/src/orocos-toolchain-2.3.1/rtt/rtt/os/tlsf/tlsf.c:631&#10;&gt; #3  0x00000000004429b0 in&#10;&gt; RTT::os::rt_allocator&lt;boost::detail::sp_counted_impl_pda&lt;RTT::internal::LocalOperationCaller&lt;void&#10;&gt; ()()&gt;*,&#10;&gt; boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt;&#10;&gt; &gt;, RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt; &gt;&#10;&gt; &gt;::allocate(unsigned long,&#10;&gt; boost::detail::sp_counted_impl_pda&lt;RTT::internal::LocalOperationCaller&lt;void&#10;&gt; ()()&gt;*,&#10;&gt; boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt;&#10;&gt; &gt;, RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt; &gt;&#10;&gt; const*) (this=0x7fffffffdeff, n=1) at&#10;&gt; /usr/local/include/rtt/internal/../internal/../os/oro_allocator.hpp:276&#10;&gt; #4  0x0000000000441557 in&#10;&gt; shared_count&lt;RTT::internal::LocalOperationCaller&lt;void()&gt;*,&#10;&gt; boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt;,&#10;&gt; RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt; &gt; (&#10;&gt;     this=0x7fffffffe0d8, p=0x0, d=..., a=...) at&#10;&gt; /usr/include/boost/smart_ptr/detail/shared_count.hpp:159&#10;&gt; #5  0x000000000043fee3 in&#10;&gt; shared_ptr&lt;RTT::internal::LocalOperationCaller&lt;void()&gt;,&#10;&gt; boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt;,&#10;&gt; RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt; &gt; (&#10;&gt;     this=0x7fffffffe0d0, p=0x0, d=..., a=...) at&#10;&gt; /usr/include/boost/smart_ptr/shared_ptr.hpp:205&#10;&gt; #6  0x000000000043df36 in&#10;&gt; boost::shared_ptr&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;&#10;&gt; boost::allocate_shared&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt;,&#10;&gt; RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;,&#10;&gt; RTT::internal::LocalOperationCaller&lt;void ()()&gt;&#10;&gt; &gt;(RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;&#10;&gt; const&amp;, RTT::internal::LocalOperationCaller&lt;void ()()&gt; const&amp;) (a=...,&#10;&gt; a1=...)&#10;&gt;     at /usr/include/boost/smart_ptr/make_shared.hpp:197&#10;&gt; #7  0x000000000043c9d8 in RTT::internal::LocalOperationCaller&lt;void&#10;&gt; ()()&gt;::cloneRT() const (this=0x6614d0) at&#10;&gt; /usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:666&#10;&gt; #8  0x000000000043db7d in RTT::internal::LocalOperationCallerImpl&lt;void&#10;&gt; ()()&gt;::send_impl() (this=0x6614d0) at&#10;&gt; /usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:166&#10;&gt; #9  0x000000000043dc14 in RTT::internal::LocalOperationCallerImpl&lt;void&#10;&gt; ()()&gt;::call_impl() (this=0x6614d0) at&#10;&gt; /usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:327&#10;&gt; #10 0x000000000043c1f0 in RTT::internal::InvokerImpl&lt;0, void ()(),&#10;&gt; RTT::internal::LocalOperationCallerImpl&lt;void ()()&gt; &gt;::call() (this=0x6614d0)&#10;&gt; at /usr/local/include/rtt/internal/../internal/Invoker.hpp:75&#10;&gt; #11 0x00000000004352d0 in RTT::internal::InvokerSignature&lt;0, void ()(),&#10;&gt; boost::shared_ptr&lt;RTT::base::OperationCallerBase&lt;void ()()&gt; &gt;&#10;&gt; &gt;::operator()() (this=0x7fffffffe348) at&#10;&gt; /usr/local/include/rtt/internal/InvokerSignature.hpp:75&#10;&gt; #12 0x0000000000433dcb in main (argc=1, argv=0x7fffffffe618) at&#10;&gt; /home/hamelinp/devroot/SM/trunk/libs/orocos-utils/test/testSMTaskContext/testSMTaskContext.cpp:144&#10;&gt;
>
> It crashed in oro_rt_malloc so I initialized the memory pool
> (init_memory_pool) and the problem is fixed. Why does calling an operation
> in the component thread require to initialize the TSLF memory pool?
>
> Philippe
>
>
> --
> Orocos-Dev mailing list
> Orocos-Dev [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-dev
>
>

Segfault when calling an operation in OwnThread without TSLF ini

On Jun 9, 2011, at 11:24 , Adolfo Rodríguez Tsouroukdissian wrote:

>
>
> On Thu, Jun 9, 2011 at 5:07 PM, Philippe Hamelin <philippe [dot] hamelin [..] ...> wrote:
> Hello,
>
> I'm not sure this is a bug or I misunderstand something. I have Orocos-RTT 2.3.1 compiled with RT_MALLOC enabled. I have this simple test case:
>
> &#10;&gt; #include &lt;rtt/TaskContext.hpp&gt;&#10;&gt; #include &lt;rtt/Property.hpp&gt;&#10;&gt; #include &lt;rtt/Operation.hpp&gt;&#10;&gt; #include &lt;rtt/Port.hpp&gt;&#10;&gt; #include &lt;rtt/RTT.hpp&gt;&#10;&gt; &#10;&gt; class PingTaskContext : public RTT::TaskContext&#10;&gt; {&#10;&gt; &#10;&gt; public:&#10;&gt; &#10;&gt;     void ping() { }&#10;&gt; &#10;&gt;     PingTaskContext(const std::string &amp;name) :&#10;&gt;         RTT::TaskContext(name)&#10;&gt;     {&#10;&gt;         this-&gt;addOperation(&quot;pingClientThread&quot;, &amp;PingTaskContext::ping,&#10;&gt;                 this, RTT::ClientThread).doc(&quot;Ping using the client thread.&quot;);&#10;&gt;         this-&gt;addOperation(&quot;pingOwnThread&quot;, &amp;PingTaskContext::ping,&#10;&gt;                 this, RTT::OwnThread).doc(&quot;Ping using the component thread.&quot;);&#10;&gt;     }&#10;&gt; &#10;&gt;     virtual ~PingTaskContext() {}&#10;&gt; &#10;&gt; };&#10;&gt; &#10;&gt; int main(int argc, char* argv[])&#10;&gt; {&#10;&gt;     PingTaskContext ptc(&quot;ptc&quot;);&#10;&gt;     ptc.setActivity(new RTT::Activity(5, 0.01));&#10;&gt; &#10;&gt;     // Test call to pingClientThread through an OperationCaller&#10;&gt;     RTT::OperationCaller&lt;void(void)&gt; pingClientThread = ptc.getOperation(&quot;pingClientThread&quot;);&#10;&gt;     pingClientThread(); // OK&#10;&gt; &#10;&gt;     // Test call to pingOwnThread through an OperationCaller&#10;&gt;     RTT::OperationCaller&lt;void(void)&gt; pingOwnThread = ptc.getOperation(&quot;pingOwnThread&quot;);&#10;&gt;     pingOwnThread(); // SEGFAULT&#10;&gt; }&#10;&gt; &#10;&gt; A shot in the dark: Try using ORO_MAIN instead of the regular main function. It wouldn&#039;t surprise me that ORO_MAIN performs some TLSF initialization code (set the memory pool?). If ORO_MAIN is not an option, verify whether you should be doing some explicit TLSF configuration before using it. What do the experts have to say here, Stephen?, Peter?.&#10;&#10;If you&#039;re not actually using any rt_strings, you don&#039;t have to worry about it IIRC.&#10;&#10;I don&#039;t believe that Orocos does any TLSF initialization by default.&#10;&#10;For TLSF init, see OCL&#039;s bin/deployer.cpp. We need to migrate this init code into a class, and install that, so users in exactly Philippe&#039;s situation can do this (we&#039;ve done that internally, and when I get a chance to breathe, I&#039;ll push that). Basically, handling TLSF memory pools.&#10;S&#10;&#10;&#10;&#10;&gt; &#10;&gt; Adolfo.&#10;&gt; &#10;&gt;
>
> The application generates a segmentation fault when calling pingOwnThread(). Here is the backtrace:
>
> &#10;&gt; #0  0x00007ffff6edf3c4 in pthread_mutex_lock () from /lib/libpthread.so.0&#10;&gt; #1  0x00007ffff6c2f694 in rtos_mutex_lock (size=184) at /usr/local/src/orocos-toolchain-2.3.1/rtt/rtt/os/tlsf/../gnulinux/fosi.h:237&#10;&gt; #2  oro_rt_malloc (size=184) at /usr/local/src/orocos-toolchain-2.3.1/rtt/rtt/os/tlsf/tlsf.c:631&#10;&gt; #3  0x00000000004429b0 in RTT::os::rt_allocator&lt;boost::detail::sp_counted_impl_pda&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt;*, boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;, RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt; &gt; &gt;::allocate(unsigned long, boost::detail::sp_counted_impl_pda&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt;*, boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;, RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt; &gt; const*) (this=0x7fffffffdeff, n=1) at /usr/local/include/rtt/internal/../internal/../os/oro_allocator.hpp:276&#10;&gt; #4  0x0000000000441557 in shared_count&lt;RTT::internal::LocalOperationCaller&lt;void()&gt;*, boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt;, RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt; &gt; (&#10;&gt;     this=0x7fffffffe0d8, p=0x0, d=..., a=...) at /usr/include/boost/smart_ptr/detail/shared_count.hpp:159&#10;&gt; #5  0x000000000043fee3 in shared_ptr&lt;RTT::internal::LocalOperationCaller&lt;void()&gt;, boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt;, RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt; &gt; (&#10;&gt;     this=0x7fffffffe0d0, p=0x0, d=..., a=...) at /usr/include/boost/smart_ptr/shared_ptr.hpp:205&#10;&gt; #6  0x000000000043df36 in boost::shared_ptr&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt; boost::allocate_shared&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt;, RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;, RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;(RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt; const&amp;, RTT::internal::LocalOperationCaller&lt;void ()()&gt; const&amp;) (a=..., a1=...)&#10;&gt;     at /usr/include/boost/smart_ptr/make_shared.hpp:197&#10;&gt; #7  0x000000000043c9d8 in RTT::internal::LocalOperationCaller&lt;void ()()&gt;::cloneRT() const (this=0x6614d0) at /usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:666&#10;&gt; #8  0x000000000043db7d in RTT::internal::LocalOperationCallerImpl&lt;void ()()&gt;::send_impl() (this=0x6614d0) at /usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:166&#10;&gt; #9  0x000000000043dc14 in RTT::internal::LocalOperationCallerImpl&lt;void ()()&gt;::call_impl() (this=0x6614d0) at /usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:327&#10;&gt; #10 0x000000000043c1f0 in RTT::internal::InvokerImpl&lt;0, void ()(), RTT::internal::LocalOperationCallerImpl&lt;void ()()&gt; &gt;::call() (this=0x6614d0) at /usr/local/include/rtt/internal/../internal/Invoker.hpp:75&#10;&gt; #11 0x00000000004352d0 in RTT::internal::InvokerSignature&lt;0, void ()(), boost::shared_ptr&lt;RTT::base::OperationCallerBase&lt;void ()()&gt; &gt; &gt;::operator()() (this=0x7fffffffe348) at /usr/local/include/rtt/internal/InvokerSignature.hpp:75&#10;&gt; #12 0x0000000000433dcb in main (argc=1, argv=0x7fffffffe618) at /home/hamelinp/devroot/SM/trunk/libs/orocos-utils/test/testSMTaskContext/testSMTaskContext.cpp:144&#10;&gt;
>
> It crashed in oro_rt_malloc so I initialized the memory pool (init_memory_pool) and the problem is fixed. Why does calling an operation in the component thread require to initialize the TSLF memory pool?
>
> Philippe
>
>
> --
> Orocos-Dev mailing list
> Orocos-Dev [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-dev
>
>
>
>

Segfault when calling an operation in OwnThread without TSLF ini

2011/6/9 Adolfo Rodríguez Tsouroukdissian <adolfo [dot] rodriguez [..] ...
>

>
>
> On Thu, Jun 9, 2011 at 5:07 PM, Philippe Hamelin <
> philippe [dot] hamelin [..] ...> wrote:
>
>> Hello,
>>
>> I'm not sure this is a bug or I misunderstand something. I have Orocos-RTT
>> 2.3.1 compiled with RT_MALLOC enabled. I have this simple test case:
>>
>> &#10;&gt;&gt; #include &lt;rtt/TaskContext.hpp&gt;&#10;&gt;&gt; #include &lt;rtt/Property.hpp&gt;&#10;&gt;&gt; #include &lt;rtt/Operation.hpp&gt;&#10;&gt;&gt; #include &lt;rtt/Port.hpp&gt;&#10;&gt;&gt; #include &lt;rtt/RTT.hpp&gt;&#10;&gt;&gt;&#10;&gt;&gt; class PingTaskContext : public RTT::TaskContext&#10;&gt;&gt; {&#10;&gt;&gt;&#10;&gt;&gt; public:&#10;&gt;&gt;&#10;&gt;&gt;     void ping() { }&#10;&gt;&gt;&#10;&gt;&gt;     PingTaskContext(const std::string &amp;name) :&#10;&gt;&gt;         RTT::TaskContext(name)&#10;&gt;&gt;     {&#10;&gt;&gt;         this-&gt;addOperation(&quot;pingClientThread&quot;, &amp;PingTaskContext::ping,&#10;&gt;&gt;                 this, RTT::ClientThread).doc(&quot;Ping using the client&#10;&gt;&gt; thread.&quot;);&#10;&gt;&gt;         this-&gt;addOperation(&quot;pingOwnThread&quot;, &amp;PingTaskContext::ping,&#10;&gt;&gt;                 this, RTT::OwnThread).doc(&quot;Ping using the component&#10;&gt;&gt; thread.&quot;);&#10;&gt;&gt;     }&#10;&gt;&gt;&#10;&gt;&gt;     virtual ~PingTaskContext() {}&#10;&gt;&gt;&#10;&gt;&gt; };&#10;&gt;&gt;&#10;&gt;&gt; int main(int argc, char* argv[])&#10;&gt;&gt; {&#10;&gt;&gt;     PingTaskContext ptc(&quot;ptc&quot;);&#10;&gt;&gt;     ptc.setActivity(new RTT::Activity(5, 0.01));&#10;&gt;&gt;&#10;&gt;&gt;     // Test call to pingClientThread through an OperationCaller&#10;&gt;&gt;     RTT::OperationCaller&lt;void(void)&gt; pingClientThread =&#10;&gt;&gt; ptc.getOperation(&quot;pingClientThread&quot;);&#10;&gt;&gt;     pingClientThread(); // OK&#10;&gt;&gt;&#10;&gt;&gt;     // Test call to pingOwnThread through an OperationCaller&#10;&gt;&gt;     RTT::OperationCaller&lt;void(void)&gt; pingOwnThread =&#10;&gt;&gt; ptc.getOperation(&quot;pingOwnThread&quot;);&#10;&gt;&gt;     pingOwnThread(); // SEGFAULT&#10;&gt;&gt; }&#10;&gt;&gt;&#10;&gt;&#10;&gt; A shot in the dark: Try using ORO_MAIN instead of the regular main&#10;&gt; function. It wouldn&#039;t surprise me that ORO_MAIN performs some TLSF&#10;&gt; initialization code (set the memory pool?). If ORO_MAIN is not an option,&#10;&gt; verify whether you should be doing some explicit TLSF configuration before&#10;&gt; using it. What do the experts have to say here, Stephen?, Peter?.&#10;&gt;&#10;&#10;I didn&#039;t read the last line of the message before, so ignore this post.&#10;&#10;&gt;&#10;&gt; Adolfo.&#10;&gt;&#10;&gt;
>>
>> The application generates a segmentation fault when
>> calling pingOwnThread(). Here is the backtrace:
>>
>> &#10;&gt;&gt; #0  0x00007ffff6edf3c4 in pthread_mutex_lock () from /lib/libpthread.so.0&#10;&gt;&gt; #1  0x00007ffff6c2f694 in rtos_mutex_lock (size=184) at&#10;&gt;&gt; /usr/local/src/orocos-toolchain-2.3.1/rtt/rtt/os/tlsf/../gnulinux/fosi.h:237&#10;&gt;&gt; #2  oro_rt_malloc (size=184) at&#10;&gt;&gt; /usr/local/src/orocos-toolchain-2.3.1/rtt/rtt/os/tlsf/tlsf.c:631&#10;&gt;&gt; #3  0x00000000004429b0 in&#10;&gt;&gt; RTT::os::rt_allocator&lt;boost::detail::sp_counted_impl_pda&lt;RTT::internal::LocalOperationCaller&lt;void&#10;&gt;&gt; ()()&gt;*,&#10;&gt;&gt; boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt;&#10;&gt;&gt; &gt;, RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt; &gt;&#10;&gt;&gt; &gt;::allocate(unsigned long,&#10;&gt;&gt; boost::detail::sp_counted_impl_pda&lt;RTT::internal::LocalOperationCaller&lt;void&#10;&gt;&gt; ()()&gt;*,&#10;&gt;&gt; boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt;&#10;&gt;&gt; &gt;, RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt; &gt;&#10;&gt;&gt; const*) (this=0x7fffffffdeff, n=1) at&#10;&gt;&gt; /usr/local/include/rtt/internal/../internal/../os/oro_allocator.hpp:276&#10;&gt;&gt; #4  0x0000000000441557 in&#10;&gt;&gt; shared_count&lt;RTT::internal::LocalOperationCaller&lt;void()&gt;*,&#10;&gt;&gt; boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt;,&#10;&gt;&gt; RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt; &gt; (&#10;&gt;&gt;     this=0x7fffffffe0d8, p=0x0, d=..., a=...) at&#10;&gt;&gt; /usr/include/boost/smart_ptr/detail/shared_count.hpp:159&#10;&gt;&gt; #5  0x000000000043fee3 in&#10;&gt;&gt; shared_ptr&lt;RTT::internal::LocalOperationCaller&lt;void()&gt;,&#10;&gt;&gt; boost::detail::sp_ms_deleter&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt;,&#10;&gt;&gt; RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void()&gt; &gt; &gt; (&#10;&gt;&gt;     this=0x7fffffffe0d0, p=0x0, d=..., a=...) at&#10;&gt;&gt; /usr/include/boost/smart_ptr/shared_ptr.hpp:205&#10;&gt;&gt; #6  0x000000000043df36 in&#10;&gt;&gt; boost::shared_ptr&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;&#10;&gt;&gt; boost::allocate_shared&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt;,&#10;&gt;&gt; RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;,&#10;&gt;&gt; RTT::internal::LocalOperationCaller&lt;void ()()&gt;&#10;&gt;&gt; &gt;(RTT::os::rt_allocator&lt;RTT::internal::LocalOperationCaller&lt;void ()()&gt; &gt;&#10;&gt;&gt; const&amp;, RTT::internal::LocalOperationCaller&lt;void ()()&gt; const&amp;) (a=...,&#10;&gt;&gt; a1=...)&#10;&gt;&gt;     at /usr/include/boost/smart_ptr/make_shared.hpp:197&#10;&gt;&gt; #7  0x000000000043c9d8 in RTT::internal::LocalOperationCaller&lt;void&#10;&gt;&gt; ()()&gt;::cloneRT() const (this=0x6614d0) at&#10;&gt;&gt; /usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:666&#10;&gt;&gt; #8  0x000000000043db7d in RTT::internal::LocalOperationCallerImpl&lt;void&#10;&gt;&gt; ()()&gt;::send_impl() (this=0x6614d0) at&#10;&gt;&gt; /usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:166&#10;&gt;&gt; #9  0x000000000043dc14 in RTT::internal::LocalOperationCallerImpl&lt;void&#10;&gt;&gt; ()()&gt;::call_impl() (this=0x6614d0) at&#10;&gt;&gt; /usr/local/include/rtt/internal/../internal/LocalOperationCaller.hpp:327&#10;&gt;&gt; #10 0x000000000043c1f0 in RTT::internal::InvokerImpl&lt;0, void ()(),&#10;&gt;&gt; RTT::internal::LocalOperationCallerImpl&lt;void ()()&gt; &gt;::call() (this=0x6614d0)&#10;&gt;&gt; at /usr/local/include/rtt/internal/../internal/Invoker.hpp:75&#10;&gt;&gt; #11 0x00000000004352d0 in RTT::internal::InvokerSignature&lt;0, void ()(),&#10;&gt;&gt; boost::shared_ptr&lt;RTT::base::OperationCallerBase&lt;void ()()&gt; &gt;&#10;&gt;&gt; &gt;::operator()() (this=0x7fffffffe348) at&#10;&gt;&gt; /usr/local/include/rtt/internal/InvokerSignature.hpp:75&#10;&gt;&gt; #12 0x0000000000433dcb in main (argc=1, argv=0x7fffffffe618) at&#10;&gt;&gt; /home/hamelinp/devroot/SM/trunk/libs/orocos-utils/test/testSMTaskContext/testSMTaskContext.cpp:144&#10;&gt;&gt;
>>
>> It crashed in oro_rt_malloc so I initialized the memory pool
>> (init_memory_pool) and the problem is fixed. Why does calling an operation
>> in the component thread require to initialize the TSLF memory pool?
>>
>> Philippe
>>
>>
>> --
>> Orocos-Dev mailing list
>> Orocos-Dev [..] ...
>> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-dev
>>
>>
>
>
> --
> Adolfo Rodríguez Tsouroukdissian
>
> Robotics engineer
> PAL ROBOTICS S.L
> http://www.pal-robotics.com
> Tel. +34.93.414.53.47
> Fax.+34.93.209.11.09
>
> CONFIDENTIALITY NOTICE: This e-mail and the accompanying document(s) may
> contain confidential information which is privileged and intended only for
> the individual or entity to whom they are addressed. If you are not the
> intended recipient, you are hereby notified that any disclosure, copying,
> distribution or use of this e-mail and/or accompanying document(s) is
> strictly prohibited. If you have received this e-mail in error, please
> immediately notify the sender at the above e-mail address.
>