Re: [Boost-users] [boost][msm] std::vector<MyStateMachine> generate stack overflow
Hi,
while playing with MSM using VS2010+SP1 in a very simple test project (I'm really just trying to test how to organize states classes in files), I've tried to see if I was able to create as many state machines as I wanted, so I started to write a simple
std::vector<MyStateMachine> state_machines(42);
Here MyStateMachine is an empty state machine class with default front-end and back-end, with only two empty states.
VC10.1 produce a warning on this line saying that there will be a stack overflow because there is a runtime recursion. I checked, it does crash (in debug at least).
I'd be quite surprised that it has much to do with the vector. I tried for security on a tutorial and all works ok. I'd more likely suspect an incorrect state machine definition, but without code I cannot help you much. Regards, Christophe
I'd be quite surprised that it has much to do with the vector. I tried for security on a tutorial and all works ok. I'd more likely suspect an incorrect state machine definition, but without code I cannot help you much.
I agree that i might have missed something, I was trying to setup the simplest state machine I could with only two states and one transition. I attached the full project (vs2010 files included) to this email. Just to point the potential problem, I defined the state machine class (RealStateMachine) this way : class StateMachine : public boost::msm::front::state_machine_def< StateMachine > { public: typedef State_HelloWorld initial_state; struct transition_table : public boost::mpl::vector < _row< State_HelloWorld, event::exit, State_Exit > > {}; StateMachine(); ~StateMachine(); }; class RealStateMachine : public boost::msm::back::state_machine< StateMachine > { public: }; Joël Lamotte.
2011/5/19 Klaim - Joël Lamotte
I'd be quite surprised that it has much to do with the vector.
It's not the vector, it's the copy constructor. You can see the same problem with : RealStateMachine sma; RealStateMachine smb( sma ); At the moment I'm not sure exactly what makes it a recursive call. Was the generated state machine not thought to be copied, or did I made a mistake? Joël Lamotte
participants (2)
-
Christophe Henry
-
Klaim - Joël Lamotte