For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=634>
Summary: Events lost in state machine
Product: RTT
Version: rtt-trunk
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P3
Component: Real-Time Toolkit (RTT)
AssignedTo: orocos-dev [..] ...
ReportedBy: kiwi [dot] net [..] ...
CC: orocos-dev [..] ...
Estimated Hours: 0.0
With two tasks firing an event when started, the second event produces a
rejected transition from the initial state (when the state machine is already
in the next state based on the first event).
Test case + state machine attached.
Output is
0.235 [ Debug ][StateMachine] Entering state UNCONNECTED 0.236 [ Info ][Telemetry] Telemetry areConnected() fired 0.237 [ Info ][Commands] Commands areConnected() fired 0.435 [ Debug ][StateMachine] Valid transition from UNCONNECTED to TELEMETRY_CONNECTED. 0.435 [ Debug ][StateMachine] Leaving state UNCONNECTED 0.435 [ Debug ][StateMachine] Entering state TELEMETRY_CONNECTED 0.435 [ ERROR ][StateMachine] Rejected transition from UNCONNECTED within TELEMETRY_CONNECTED: wrong state.
NB: Peter my state machine implementation has debugging mod's you added a while
back, when we were chasing another SM bug. Diff attached also.
[Bug 634] Events lost in state machine
For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=634>
S Roderick <kiwi [dot] net [..] ...> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution| |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #11 from S Roderick <kiwi [dot] net [..] ...> 2009-03-22 21:40:29 ---
Fixed by patch
[Bug 634] Events lost in state machine
For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=634>
--- Comment #10 from Peter Soetens <peter [dot] soetens [..] ...> 2009-03-22 21:37:46 ---
(In reply to comment #9)
> Final state is correct, however, still get errors.
>
>
These aren't errors but expected behaviour. You should not print these
'Rejected' diagnostics, and I will not add them on trunk. What I had to do is
enabled all event handlers for all states. Say event E can cause transitions in
3 states, then it will call all three handlers. The state machine will only
allow the transition handler if it causes a transition from the current state.
All others will be 'rejected'. It's less efficient, but it's causing at least
correct behaviour.
Peter
[Bug 634] Events lost in state machine
For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=634>
--- Comment #9 from S Roderick <kiwi [dot] net [..] ...> 2009-03-21 17:58:33 ---
Final state is correct, however, still get errors.
[Bug 634] Events lost in state machine
For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=634>
--- Comment #8 from Peter Soetens <peter [dot] soetens [..] ...> 2009-03-20 17:28:20 ---
Stephen, could you confirm that your bug has been fixed by (if so) marking it
as resolved ?
Thanks,
Peter
[Bug 634] Events lost in state machine
Turns out this fix also trashes existing state machines we have. Get
the same "rejected transition" errors but for events that are
*possible* but have definitely not fired (they have to come from
user). It still seems to transition correctly though ...
S
On Mar 20, 2009, at 12:28 , Peter Soetens wrote:
> For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=634
> >
>
>
>
>
> --- Comment #8 from Peter Soetens <peter [dot] soetens [..] ...>
> 2009-03-20 17:28:20 ---
> Stephen, could you confirm that your bug has been fixed by (if so)
> marking it
> as resolved ?
>
> Thanks,
> Peter
[Bug 634] Events lost in state machine
For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=634>
--- Comment #7 from Peter Soetens <peter [dot] soetens [..] ...> 2009-03-18 11:34:46 ---
(In reply to comment #6)
> Created an attachment (id=403)
--> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=403) [details]
> Should fix this bug. Patch against trunk.
>
> This change/fix at least doesn't break the unit tests, but I didn't test it
> with your example code. Could you verify it in your setup ? Only requires
> recompilation of RTT, not the application or other libraries.
It seems to fix the example. I end up in the CONNECTED state.
Peter
[Bug 634] Events lost in state machine
For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=634>
--- Comment #6 from Peter Soetens <peter [dot] soetens [..] ...> 2009-03-18 11:26:01 ---
Created an attachment (id=403)
--> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=403)
Should fix this bug. Patch against trunk.
This change/fix at least doesn't break the unit tests, but I didn't test it
with your example code. Could you verify it in your setup ? Only requires
recompilation of RTT, not the application or other libraries.
Peter
[Bug 634] Events lost in state machine
For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=634>
Peter Soetens <peter [dot] soetens [..] ...> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |1.8.1
CC| |peter [dot] soetens [..] ...
Status|NEW |ASSIGNED
--- Comment #5 from Peter Soetens <peter [dot] soetens [..] ...> 2009-03-18 11:02:31 ---
(In reply to comment #4)
> Reviewing this, I don't think I described the problem well enough.
>
> Two tasks are started and both fire an "areConnected" event. An existing task
> with a state machine processes these two events, and I expect two transitions
> to occur. One from UNCONNECTED to TELEMETRY_CONNECTED with the first event, and
> another transition from TELEMETRY_CONNECTED to CONNECTED due to the second
> event.
>
> Instead, the first event is processed as expected but the second event is
> rejected as an illegal transition out of the UNCONNECTED state when the SM is
> already in the TELEMETRY_CONNECTED state. Shouldn't this second event be
> processed from within the TELEMETRY_CONNECTED state?
>
> Is my expectation wrong here, or is this a bug?
Thanks for nailing this one down.
In a way it's a bug... The state machine has for each event reception declared
in each state an event handler. When it enters the state, the handlers are
enabled, when left, they are disabled. This means that for your
Telemetry.areConnected event, two handlers exist, but for different states. If
a handler is called which was enabled in an older state, the SM code discards
it.
We may work around/solve this by enabling all event handlers once the state
machine is activated and just discard 'not-for-this-state events' as we're
doing now. It's probably a small patch, and will solve all cases similar to
your case (which looks a very common one).
I'm working on it.
[Bug 634] Events lost in state machine
For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=634>
--- Comment #4 from S Roderick <kiwi [dot] net [..] ...> 2009-03-17 13:44:57 ---
Reviewing this, I don't think I described the problem well enough.
Two tasks are started and both fire an "areConnected" event. An existing task
with a state machine processes these two events, and I expect two transitions
to occur. One from UNCONNECTED to TELEMETRY_CONNECTED with the first event, and
another transition from TELEMETRY_CONNECTED to CONNECTED due to the second
event.
Instead, the first event is processed as expected but the second event is
rejected as an illegal transition out of the UNCONNECTED state when the SM is
already in the TELEMETRY_CONNECTED state. Shouldn't this second event be
processed from within the TELEMETRY_CONNECTED state?
Is my expectation wrong here, or is this a bug?
[Bug 634] Events lost in state machine
For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=634>
--- Comment #3 from S Roderick <kiwi [dot] net [..] ...> 2009-03-17 02:42:25 ---
Created an attachment (id=401)
--> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=401)
Diff
[Bug 634] Events lost in state machine
For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=634>
--- Comment #2 from S Roderick <kiwi [dot] net [..] ...> 2009-03-17 02:41:50 ---
Created an attachment (id=400)
--> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=400)
State machine file
[Bug 634] Events lost in state machine
For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=634>
--- Comment #1 from S Roderick <kiwi [dot] net [..] ...> 2009-03-17 02:41:22 ---
Created an attachment (id=399)
--> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=399)
Test file