W3C home > Mailing lists > Public > www-voice@w3.org > April to June 2012

Re: Potential Bug in scxml Interpreter-Algorithm

From: Tim Langner <tim.langner@metralabs.com>
Date: Thu, 07 Jun 2012 09:25:25 +0200
Message-ID: <4FD05765.3080306@metralabs.com>
To: DOLECEK Ales <Ales.Dolecek@nextiraone.eu>
CC: "www-voice@w3.org" <www-voice@w3.org>
The following example will reproduce the bug. I attach also a trace of 
the output of my implementation.

After start the configuration will be:

{TopState, State1, State11}

Sending event TO_STATE12
Leaving state State11
Fire transition State11->State12
Entering state State12

Sending event TO_STATE22
Leaving state State12
Leaving state State1
Fire transition State12->State22
Entering state State2
Entering state State22

Sending event STATE22_TO_HISTORY
Leaving state State22
Leaving state State2
Fire transition State22->S1History
Entering state TopState
Entering state State1
Entering state State12

You can see that we enter TopState which is not correct. This is caused 
by the follwoing code:

if isHistoryState(state):
   if historyValue[state.id]:
     for s in historyValue[state.id]:
       addStatesToEnter(s,statesToEnter,statesForDefaultEntry)
         for anc in getProperAncestors(s,state):
           statesToEnter.add(anc)

For state = S1History and s = State12 getProperAncestors(State12, 
S1History) will not stop at S1History since it is no direct ancestor of 
State12 so it will add TopState to the states to enter.

This is the scxml code:

<scxml initial="StateMachineInitial">
  <state id="TopState">
    <state id="State2">
      <state id="State21">
        <transition event="STATE21_TO_HISTORY" target="S1History"/>
      </state>
      <state id="State22">
        <transition event="STATE22_TO_HISTORY" target="S1History"/>
      </state>
      <initial>
        <transition target="State21"/>
      </initial>
    </state>
    <initial>
      <transition target="State1"/>
    </initial>
    <state id="State1">
      <state id="State12">
        <transition event="TO_STATE22" target="State22"/>
        <transition event="TO_STATE11" target="State11"/>
      </state>
      <state id="State11">
        <transition event="TO_STATE21" target="State21"/>
        <transition event="TO_STATE12" target="State12"/>
      </state>
      <history id="S1History" type="deep">
        <transition target="State11"/>
      </history>
      <initial>
        <transition target="State11"/>
      </initial>
    </state>
    <transition event="END" target="StateMachineFinal"/>
  </state>
  <state id="StateMachineInitial">
    <transition target="TopState"/>
  </state>
  <final id="StateMachineFinal"/>
</scxml>

Tim

Am 06.06.2012 11:41, schrieb DOLECEK Ales:
> Hello Tim,
>
>    can you add simple SCXML document that demonstrates the bug.
>
> Aleš
>
> -----Original Message-----
> From: Tim Langner [mailto:tim.langner@metralabs.com]
> Sent: Tuesday, June 05, 2012 1:36 PM
> To: www-voice@w3.org
> Subject: Potential Bug in scxml Interpreter-Algorithm
>
> Hi,
>
> I found a potential bug in the pseudo algorithm of the scxml interpreter.
>
> In procedure
> addStatesToEnter(state,root,statesToEnter,statesForDefaultEntry)
>
> there is a if clause for history states:
>
> if historyValue[state.id]:
>     for s in historyValue[state.id]:
>       addStatesToEnter(s,statesToEnter,statesForDefaultEntry)
>         for anc in getProperAncestors(s,state):
>           statesToEnter.add(anc)
>
> However calling getProperAncestors(s,state) for state where state is a history state will collect all ancestors up to the scxml root element because history states have no childs. This results in leaving and entering all parent states (up to the scxml root) when going back into a history state.
> I propose to fix this by calling:
> getProperAncestors(s,state.parent):
>
>
> Best Regards,
> Tim Langner
>
> --
> MetraLabs GmbH
> Neue Technologien und Systeme
>
> Dipl.-Inf. Tim Langner
> Software-Engineering
>
> E-mail:	Tim.Langner@MetraLabs.com
> Phone:	+49 - 36 77 - 667 431 32
> Fax: 	+49 - 36 77 - 667 431 99
>
> Internet: http://www.MetraLabs.com
> Address: Am Vogelherd 22, D-98693 Ilmenau Trade register : Amtsgericht Jena, HRB 305694 Managing Director: Dr. Andreas Bley, Matthias Merten European VAT ID: DE214004108
>
> This e-mail including the attached documents are confidential and may contain privileged information. The unauthorized use of such information is illegal. If you are not the intended recipient, please delete this Email and notify the sender. The content of the e-mail and its attachments are protected by copyright law.
>
>
>
Received on Thursday, 7 June 2012 07:31:08 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 7 June 2012 07:31:16 GMT