[Bug 642] New: Race condition causes commands not to be executed

For more infomation about this bug, visit https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=642
Summary: Race condition causes commands not to be executed
Product: RTT
Version: 1.8.0
Platform: All
OS/Version: All
Status: NEW
Severity: major
Priority: P3
Component: Real-Time Toolkit (RTT)
AssignedTo: orocos-dev [..] ...
ReportedBy: peter [dot] soetens [..] ...
CC: orocos-dev [..] ...
Estimated Hours: 0.0

There's a race in the command implementation (LocalCommand.hpp) which may cause
commands not to be executed. The two functions involved are:

           // queues the command in the CommandProcessor (mcp)
            virtual bool dispatch() {
                if (this->minvoked && !this->done() ) // if invoked and not
ready.
                    return false;
                this->reset();
                this->maccept = this->mcp->process( this );
                this->minvoked = true;
                return this->maccept;
            }
 
           // executes the queued command (called by step() )
            virtual bool execute() {
                // do not allow to execute twice
                if ( !this->maccepted || this->mexec )
                    return false;
                this->mvalid = this->exec();
                this->mexec = true;
                return this->mvalid;
            }

Don't read on if you think you can find it yourself....

...thinking...

Ok. Here's the answer:
In case the CommandProcessor's process() function is preempted by it's own
step() function before it returns, maccept will still be false, causing
execute() (which is called by step() ) to return false as well, thinking that
the CP tries to execute an unaccepted command, which is very unlikely in the
first place. The correct fix is to remove the
!this->maccepted condition from the if statement.

Thanks to 'git bisect run' for pointing to the correct location of the bug.

Fixing this for 1.8.2...

Peter

[Bug 642] Race condition causes commands not to be executed

For more infomation about this bug, visit https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=642

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

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

--- Comment #1 from Peter Soetens <peter [dot] soetens [..] ...> 2009-03-27 21:57:35 ---
Fixed in RTT 1.8.2