erikzenker / hsm

Finite state machine library based on the boost hana meta programming library. It follows the principles of the boost msm and boost sml libraries, but tries to reduce own complex meta programming code to a minimum.
MIT License
187 stars 18 forks source link

[BUG] Segfault in process_events #167

Closed denzor200 closed 2 years ago

denzor200 commented 2 years ago

Describe the bug This segfault appeared when i try to use orthogonal regions with hierarchies.

To Reproduce https://godbolt.org/z/nzT5MYG91

Expected behavior I expect this test to pass successfully:

int main()
{
    hsm::sm<MainState> sm;

    sm.process_event(switch_{});
    BOOST_ASSERT(sm.is(0, hsm::state<Online>, hsm::state<S1>));
    BOOST_ASSERT(sm.is(1, hsm::state<Online>, hsm::state<S3>));

    sm.process_event(e1{});
    BOOST_ASSERT(sm.is(0, hsm::state<Online>, hsm::state<S2>));
    BOOST_ASSERT(sm.is(1, hsm::state<Online>, hsm::state<S4>));

    return 0;
}

Additionally, I expect the console output to be:

Region 0!
Region 1!

Additional context This works good when i remove "Region 1": https://godbolt.org/z/Kfbe3zean

erikzenker commented 2 years ago

Hi @denzor200 thank you very much for the report. Orthogonal regions are not very well tested with other features. I will fix the bug asap.

erikzenker commented 2 years ago

I created a minimized reproducer based on your work: https://github.com/erikzenker/hsm/pull/169

erikzenker commented 2 years ago

@denzor200 the bug was fixed with #169