[Bug 521] New: event transitions can cause crashes (in state machines,...)

For more infomation about this bug, visit
Summary: event transitions can cause crashes (in state
machines,...)
Product: RTT
Version: 1.4.0
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Scripting
AssignedTo: orocos-dev [..] ...
ReportedBy: peter [dot] soetens [..] ...
CC: orocos-dev [..] ...
Estimated Hours: 0.0

When your state machine script reacts to an asynchronous event, it may crash.
Other event related services may be affected too by this bug.

Due to an wrongly initialised value in the TaskContext constructor, the
EventService of a TaskContext uses the global CompletionProcessor instead of
the EventProcessor of the TaskContext itself (
task->events()->getEventProcessor() will always return the CompletionProcessor
).

Since the scripting framework asks the EventService which the EventProcessor
is, it gets a wrong answer and takes the wrong decisions. As a consequence
thread safety is no longer guaranteed and the event is handled at the wrong
time.

Asking the ExecutionEngine which the EventProcessor is, results in the correct
answer ( task->engine()->events() is correct )

The clean fix is to change the inheritance order of TaskContext from
class TaskContext
: public OperationInterface,
public TaskCore
to
class TaskContext
: public TaskCore,
public OperationInterface

and initialise the OperationInterface with TaskCore::engine(). A binary
compatible (RTT 1.4.1) fix is to add

// Work around for bug
this->mevents.setEventProcessor( ee->events() );

in the setup() function of the RTT::TaskContext class.

The RTT::TaskObject class suffers from the same bug, the EventService is not
correctly initialised. A thorough review is needed to check if the
OperationInterface/EventService is taken into account at all places.

[Bug 521] event transitions can cause crashes (in state machines

For more infomation about this bug, visit

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

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

--- Comment #1 from Peter Soetens
<peter [dot] soetens [..] ...> 2008-03-13 16:19:50 ---
This bug was fixed in r29023 and also merged in the RTT 1.4 branch.
The work around 'this->mevents.setEventProcessor( ee->events() );' was added in
TaskContext and similar classes, such that it is backwards compatible with RTT
1.4.x