Skip to content

bug: Events triggered via sml::back::process<TEvent>() are not processed in parent state  #562

Closed

Description

@rhaschke

Expected Behavior

Events not handled in a child state should be handled by the parent state. Duplicate of #400.

Actual Behavior

While this works for events injected via process_event() from the top-level machine, it fails for events triggered by an action via sml::back::process<TEvent>(): https://godbolt.org/z/dnMv1dfa4

Activity

  1. changed the title [-]bug: Events triggered via sml::back:process<TEvent>() are not processed in parent state [/-] [+]bug: Events triggered via `sml::back::process<TEvent>()` are not processed in parent state [/+] on Mar 6, 2023
  2. rhaschke commented on Mar 18, 2023

    @rhaschke
    ContributorAuthor

    I analyzed this issue a little bit and found that the event triggered via sml::back::processs is injected into the sub state's process queue instead of using the root state's one:

    back::process process
    return back::process<TEvents...>{sm.process_};
    aux::get<get_root_sm_t<TSubs>>(subs).process_.push(event);

    A similar issue was resolved in #302 for process, which actually works correctly now.
    I added a (failing) unit test in my fork to illustrate the problem.

    To resolve that issue here in a similar fashion, one would need to access the root sm in get_arg, which is not available yet. However, instead of applying this kind of fix again, I want to fundamentally question the design:
    Why do we need the process_ queue in all sub state machines at all? Doesn't it suffice to have a single one in the root state machine - as we need to process all events from there? All subs could simply have a pointer to that single queue instance, such that we don't need to change API of get_arg.

    For deferred events the story is different I think: they should be kept in state-local queues and be processed as soon as the state is left.

  3. PavelGuzenfeld commented on Oct 13, 2026

    @PavelGuzenfeld
    Contributor

    Fixed by #687, the repro prints the failure as expected on master 4970fef. Can be closed.

  4. PavelGuzenfeld commented on Oct 17, 2026

    @PavelGuzenfeld
    Contributor

    @kris-jusiak can you close this? Fixed or answered, see the comment above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions