fix: back::process<E> from sub-SM now routes to root SM queue (issue #400)#687
Merged
kris-jusiak merged 2 commits intoMay 27, 2026
Conversation
…oost-ext#400) Events pushed via back::process<TEvents...> from an action inside a sub-SM were queued in the sub-SM's own process_ queue instead of the root SM's. The root SM's drain loop never empties the sub-SM's queue, so those events were silently dropped after the inner dispatch returned. Root cause: the 4-parameter get_arg overload for back::process<TEvents...> received the sub-SM instance (Tsm &sm) and used sm.process_. The TSubs pool is available as a 6th argument in the call::execute path but the specific overload for back::process didn't use it. Fix: add a 6-parameter get_arg overload (preferred over the variadic fallback via the int/... trick) that retrieves the root SM via get_root_sm_t<TSubs> and binds back::process to its process_ queue. This matches the behaviour of front::actions::process (the sml::process(e) inline-action syntax), which already used get_root_sm_t correctly. Non-nested SMs are unaffected: in that case get_root_sm_t<TSubs> returns the root itself, so the queue is the same as before. Test: back_process_from_sub_sm_routes_to_root_queue in actions_process.cpp Verified: GCC C++17/C++20 (all pass), MSVC 19.51.36244 C++20 (33/33 pass)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When an action inside a sub-SM calls
back::process<E>to enqueue an event, the event is pushed to the sub-SM's ownprocess_queue instead of the root SM's. The root SM's drain loop never empties sub-SM queues, so those events are silently dropped.Minimal reproducer:
Originally reported in #400 and #562 (with a fix sketch by
rhaschke).Root cause
The 4-parameter
get_argoverload forback::process<TEvents...>receives the current SM (Tsm &sm) and bindsback::processtosm.process_. When executing a sub-SM action,smis the sub-SM — not the root. The 6-param dispatch falls through the variadic...fallback which calls the 4-param version, so the wrong queue is used.Compare with
front::actions::process(the inlinesml::process(event)syntax), which has always correctly used:aux::get<get_root_sm_t<TSubs>>(subs).process_.push(event);Fix
Add a 6-parameter
get_argoverload forback::process<TEvents...>(preferred over the...fallback via theint/...trick) that bindsback::processto the root SM's queue:For non-nested SMs
get_root_sm_t<TSubs>returns the root itself — no behaviour change for flat state machines.Verification