I may have oversimplified in my post, replacing Get() with GetEvenIfUnreachable() is a start but it’s not enough to fix the issue. Did you reproduce those crashes with the v1.5.3 version?
When the context object is destroyed, the FSMs will stop ticking and will therefore stop “running” immediately. It’s true, however, that there may be a situation where the root state object and all its FSMs stay around until the next garbage collection cycle, instead of being purged as soon as its context object is. The situation occurs only if the context object becomes unreachable without first being marked pending kill. YMMV, but I believe this case doesn’t occur very often and even if it does, the situation eventually heals itself without memory leaks.
That’s a good advice. The standalone indeed has a different behaviour from the editor, so I must be more careful and check that also. That said, I could not reproduce bugs nor crashes with your test project using v1.5.3 even on standalone.
The problem here could be that there is a situation where the call to AddReferencedObject() might nullify rootState. It has nothing to do with context having an invalid value. Adding a null check on rootState might probably be safe, I just would like to understand if it’s really needed, because I did not encounter this problem during regular use. BTW, due to the way the value of context variable is obtained (it’s the value of a UPROPERTY), a null check is ok, using IsValidLowLevel() would be a huge waste of time.
Anyway, I’m thinking of rewriting this part of GC FSM. It looks a bit fragile and I would like to make it less dependent from garbage collection internal details.