SMF smf_set_handled() bug preventing event propagation to parent states. #81300
Labels
area: State Machine Framework
State Machine Framework
bug
The issue is a bug, or the PR is fixing a bug
I think there might be a bug in the Zephyr state machine framework (SMF) that causes
smf_set_handled()
to cause future calls tosmf_run_state()
to not propagate events up the state hierarchy in HSMs in certain situations.I am using a state hierarchy in where there is a state
S1
which has multiple child statesS1A
,S1B
, e.t.c.S1A
callssmf_set_handled()
on one event, and then a second event comes it to cause the state machine to transition to other child states likeS1B
. At some point the state machine transitions back toS1A
.It is here that I've noticed that an event can come in to
S1A
, and the parent staterun()
functions are not called. I am definitely not callingsmf_set_handled()
orsmf_set_state()
in thes1a_run()
function, thus I'm not handling the event and would expect the parentrun()
functions to be called in backwards order.Unfortunately the code that causes bug is private and I cannot share it. I tried to recreate a minimal working example but haven't yet been able to trigger the bug (my attempt is here: https://github.com/gbmhunter/zephyr-examples/tree/main/apps/state-machine-framework).
Further evidence that has me thinking this is a bug with the SMF library is that if I modify
zephyr/lib/smf/smf.c
so thathandled
is set tofalse
everytimesmf_run_state()
is called, the bug goes away. To me, this seems like a reasonable thing to do, you would expect thehandled
state to be refreshed tofalse
on every invocation ofsmf_run_state()
.I am running Zephyr
v3.7.0
, the Zephyr SDKv0.17.0
and building fornative_sim
. Running this on WSL (Ubuntu).The text was updated successfully, but these errors were encountered: