-
Notifications
You must be signed in to change notification settings - Fork 768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stackoverflow when triggering state with substates and FiringMode.Immediate #439
Comments
My test code which I used to find this behavior:
|
Running
|
Thanks, I'll have too look into it. On a side note, I do not recommend using the Immediate firieng mode, as it can allow you to shoot yourself in the foot in subtle (and not so subtle) ways. |
I could not find any information on the difference between firing modes. Could you elaborate on the difference between them? |
The major difference between the modes are what happens if a trigger is fired during a transition. For instance, if there is a call to Fire in a OnEntry handler, then Immediate will execute the code to process that trigger. Queued will put the trigger in a queue and it will be processed after all the actions associated with the current transition has been completed. Queued mode guarantees Run-To-Completion (and atomic) state transitions, Immediate does not. Atomic Run-to-Completion state transitions are usually preferred, but there are use cases for out-of-order trigger handling. If a device has detected a critical condition it would require emergency shut down, and not wait to process triggers already in the queue. |
@HenningNT The stack overflow seems to be caused by below clause in stateless/src/Stateless/StateMachine.cs Lines 480 to 486 in e25f4da
When a state has an initial transition in Immediate firing mode, this clause is reverting the state representation after entering the substate. This causes an infinite loop and thus the stack overflow. Changing the line I'm currently not sure how to fix that. |
What I want is to configure my statemachine with a state that consists of several substates (i.e., actions that need to be performed right after each other prior to allowing this state to leave). From the outside it should appear as
Init
->StateA
->Exit
. Internally, the state machine does:Init
->StateA
->SubstateA1
->SubstateA2
->Exit
.If I configure the statemachine using
FiringMode.Immediate
, a stackoverflow is triggered due to continuous triggering ofStateA
. When chainging the statemachine to useFiringMode.Queued
this behaviour does not appear, and the statemachine works as expected.From my tests, it looks like the stackoverflow is only triggered when using substates in combination with
FiringMode.Immediate
. I observed this behaviour in stateless versions from 5.0.0 until 5.10.1.The text was updated successfully, but these errors were encountered: