Menu

#393 QPC 8.0.4 Nesting 5 levels can make AO become unresponsive

QP
closed
nesting (1)
1
2026-01-04
2025-10-07
Can Caglar
No

Observations:

In qep_hsm.c, QHSM_MAX_NEST_DEPTH_ is 6.

If there is an unhandled event received, as the framework looks for super-states that can handle the event, it saves it to path[] in QHsm_dispatch_.

If you have 5 levels of nesting, then the 6th one becomes QHsm_top, where this is stored in path[0].

However, path[0] is also used to save the current state on line 265 but in the scenario described above, it gets overwritten. Then at the end of the function, the new state for the function is QHsm_top and then it no longer responds to any events.

I'm not entirely sure if this explanation is accurate, so I tried to replicate the problem on one of the examples, qhsmtst, and found the problem there too, so I think perhaps there is a bug here.

To repeat:

Modify the qhsmtest example as per image so that there are 5 nesting states, and remove a transition so there is an unhandled state in that state.

  1. Enter state S2111
  2. Send some event that is not handled (in my example "H" is not handled by this state
  3. Try to leave the state by sending an event that is handled (i.e. "D" in my example)
  4. Observe that the state is not left. In fact this state will no longer respond to states.

If you repeat the above and NOT do step 3, then on step 4 the state machine DOES respond.

Discussion

  • Quantum Leaps

    Quantum Leaps - 2025-10-07

    Thanks a lot for reporting!

    Could you please check it in the latest QP 8.1.0? That version has specifically been redesigned for complete code coverage, which includes verifying all assertions.

    --MMS

     
  • Can Caglar

    Can Caglar - 2025-10-08

    Hi Dr Samek, I did try with the latest version this morning, with a modified version of qhsmtst again, and able to repeat it there too.

    Please note that this isn't hitting any assertions. If I make another level of nesting THEN the assertion is hit.

    My test and picture of state machine attached. Note how after sending the signal "H", the AO becomes unresponsive to events it used to be responsive to.

     
  • Can Caglar

    Can Caglar - 2025-10-08
    • summary: QPC 8.0.4 Nesting 5 levels can cause source state to be overwritten in QHsm_dispatch_ --> QPC 8.0.4 Nesting 5 levels can make AO become unresponsive
     
  • Quantum Leaps

    Quantum Leaps - 2025-10-08

    Thanks a lot for checking this in QP 8.1.0. Could you please attach your QM model?
    --MMS

     
  • Can Caglar

    Can Caglar - 2025-10-08

    Sure, here it is. I was experimenting with packages not so long ago, so attaching the package too - no changes to the models done, so you should be able to repeat it.

     

    Last edit: Can Caglar 2025-10-08
  • Quantum Leaps

    Quantum Leaps - 2025-10-09
    • Group: QPC --> QP
     
  • Quantum Leaps

    Quantum Leaps - 2025-10-09

    Thank you for the QM model.

    The problem is reproducible both in versions 8.0.4 and 8.1.0 (and perhaps older). With precisely 6 levels of state nesting (including the top state) an unhandled event causes the state machine to erroneously switch to the "top" state. Once in the "top" state the state machine ignores all events and so it becomes unresponsive.

    The fix is already made and tested and will be released in QP 8.1.1.

    --MMS

     
  • Quantum Leaps

    Quantum Leaps - 2026-01-04

    Fixed in QP/C/C++ 8.1.1.
    --MMS

     

Anonymous
Anonymous

Add attachments
Cancel