sml
sml copied to clipboard
Segmentation fault in guard with Mingw64 GCC, debug build
Code
#include <sml.hpp>
namespace {
struct Event {
bool pressed;
};
struct Guard1 {
[[nodiscard]] bool operator()(const Event& e) const {
return e.pressed;
}
} guard1;
struct Guard2 {
[[nodiscard]] bool operator()(const Event& e) const {
return true;
}
} guard2;
struct Guard3 {
[[nodiscard]] bool operator()(const Event& e) const {
return true;
}
} guard3;
}// namespace
namespace sml = boost::sml;
struct Fsm {
struct State {};
auto operator()() const {
using namespace boost::sml;
return make_transition_table(
// clang-format off
*state<State> + event<Event>[guard1 && guard2 && guard3] = state<State>
// clang-format on
);
}
};
int main() {
boost::sml::sm<Fsm> fsm{};
fsm.process_event(Event{});
}
Expected Behavior
No segmentation fault.
Actual Behavior
Segmentation fault when accessing the pressed
field in Guard1
.
Process finished with exit code -1073741819 (0xC0000005)
Event address is still ok in front::transition::execute
:
But in front::call::execute
it gets corrupted:
If I remove one of the guard, it works fine.
Steps to Reproduce the Problem
- use gcc from MSYS2,
gcc --version gcc.exe (Rev2, Built by MSYS2 project) 12.1.0
- build with
-g -std=gnu++20
- run
Specifications
- Version: 1.1.4, 1.1.5
- Platform: Windows, GCC 12.1.0 (MSYS2 mingw-w64-x86_64-gcc)
Hey @kris-jusiak we also experience a similar behavior in our application, so i think we can confirm, can you look into this? However we are using clang and run on linux.
Hey, will take a look, thanks for bringing it up to my attention
so it's only on mingw, correct? can't repro on gcc12.1 - https://godbolt.org/z/jos7h78vq
With mingw-clang, it seems to work.