[Bug 786] New: Segmentation fault when calling several times exported function that does nothing

https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=786

Summary: Segmentation fault when calling several times exported
function that does nothing
Product: RTT
Version: 1.10.3
Platform: i386 Compatible
OS/Version: All
Status: NEW
Severity: normal
Priority: P3
Component: Real-Time Toolkit (RTT)
AssignedTo: orocos-dev [..] ...
ReportedBy: nicolas [dot] mabire [..] ...
CC: orocos-dev [..] ...
Estimated Hours: 0.0

Created an attachment (id=613)
--> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=613)
source code to produce the bug

How to produce the bug:
- create a program that exports a function with many "do nothing" :
prg.ops : export function foo() { do nothing; do nothing; ... // repeated many
times }
- load this program from a component running in a periodic activity
- call that function several times from the task browser :

Output of the TaskBrowser (under gdb) :

In Task ATask[R]. (Status of last Command : none )
(type 'ls' for context info) :foo()
Got :foo()

In Task ATask[R]. (Status of last Command : busy )
(type 'ls' for context info) :foo()
Got :foo()
2.486 [ Warning][TaskBrowser] Stopping Function running in ProgramProcessor !

In Task ATask[R]. (Status of last Command : busy )
(type 'ls' for context info) :
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb63dcb90 (LWP 27712)]
0x00000018 in ?? ()
(gdb) bt
#0 0x00000018 in ?? ()
#1 0xb713f0b5 in RTT::ProgramProcessor::step (this=0x9b00068)
at /home/localuser/workspace/orocos/rtt/src/ProgramProcessor.cpp:192
#2 0xb710637a in RTT::ExecutionEngine::step (this=0x9aff788)
at /home/localuser/workspace/orocos/rtt/src/ExecutionEngine.cpp:309
#3 0xb71ef0e8 in RTT::PeriodicActivity::step (this=0x9b05478)
at /home/localuser/workspace/orocos/rtt/src/PeriodicActivity.cpp:178
#4 0xb714ad5e in RTT::TimerThread::step (this=0x9b05490)
at /home/localuser/workspace/orocos/rtt/src/TimerThread.cpp:146
#5 0xb720f540 in RTT::OS::periodicThread (t=0x9b05490)
at /home/localuser/workspace/orocos/rtt/src/os/PeriodicThread.cpp:106
#6 0xb6ef94c0 in start_thread () from /lib/i686/cmov/libpthread.so.0
#7 0xb6d496de in clone () from /lib/i686/cmov/libc.so.6
(gdb)

Tested with linux and xenomai, with rtt 1.10.4, ocl 1.10.2
see attached file for example

[Bug 786] Segmentation fault when calling several times exported

https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=786

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

What |Removed |Added
----------------------------------------------------------------------------
Resolution| |FIXED
Status|ASSIGNED |RESOLVED

--- Comment #2 from Peter Soetens <peter [..] ...> 2010-12-21 10:49:08 ---
Fixed in 1.12.

[Bug 786] Segmentation fault when calling several times exported

https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=786

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

What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED

--- Comment #1 from Peter Soetens <peter [..] ...> 2010-10-12 15:35:36 ---
(In reply to comment #0)
> Created an attachment (id=613)
--> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=613)
> source code to produce the bug
>
> How to produce the bug:
> - create a program that exports a function with many "do nothing" :
> prg.ops : export function foo() { do nothing; do nothing; ... // repeated many
> times }
> - load this program from a component running in a periodic activity
> - call that function several times from the task browser :
>
> Output of the TaskBrowser (under gdb) :
>
> In Task ATask[R]. (Status of last Command : none )
> (type 'ls' for context info) :foo()
> Got :foo()
>
> In Task ATask[R]. (Status of last Command : busy )
> (type 'ls' for context info) :foo()
> Got :foo()
> 2.486 [ Warning][TaskBrowser] Stopping Function running in ProgramProcessor !
>
> In Task ATask[R]. (Status of last Command : busy )
> (type 'ls' for context info) :
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 0xb63dcb90 (LWP 27712)]
> 0x00000018 in ?? ()
> (gdb) bt
> #0 0x00000018 in ?? ()
> #1 0xb713f0b5 in RTT::ProgramProcessor::step (this=0x9b00068)
> at /home/localuser/workspace/orocos/rtt/src/ProgramProcessor.cpp:192
> #2 0xb710637a in RTT::ExecutionEngine::step (this=0x9aff788)
> at /home/localuser/workspace/orocos/rtt/src/ExecutionEngine.cpp:309
> #3 0xb71ef0e8 in RTT::PeriodicActivity::step (this=0x9b05478)
> at /home/localuser/workspace/orocos/rtt/src/PeriodicActivity.cpp:178
> #4 0xb714ad5e in RTT::TimerThread::step (this=0x9b05490)
> at /home/localuser/workspace/orocos/rtt/src/TimerThread.cpp:146
> #5 0xb720f540 in RTT::OS::periodicThread (t=0x9b05490)
> at /home/localuser/workspace/orocos/rtt/src/os/PeriodicThread.cpp:106
> #6 0xb6ef94c0 in start_thread () from /lib/i686/cmov/libpthread.so.0
> #7 0xb6d496de in clone () from /lib/i686/cmov/libc.so.6
> (gdb)
>
> Tested with linux and xenomai, with rtt 1.10.4, ocl 1.10.2
> see attached file for example

This bug appears to be fixed in 1.12.0. I can't reproduce your crash with your
example it in that version. You could pick the patch from bug #766 and apply
that on your RTT 1.10.x version and see if that helps. Most likely it does.
Please report success/failure such that we can close this report.

Peter

[Bug 786] Segmentation fault when calling several times exported

I can confirm that applying the patch you suggest has corrected the problem.
Thanks for your support.

Nicolas

[Bug 786] Segmentation fault when calling several times exported

I can confirm that applying the patch you suggest has corrected the problem. Thanks for your support.

Nicolas