fsm icon indicating copy to clipboard operation
fsm copied to clipboard

crash

Open powerpeng opened this issue 9 years ago • 7 comments

It should crash if the queue std::deque< states::iterator > aborted has more than 2 elements . Your Code is useful , Thank you very much !

powerpeng avatar Dec 28 '15 07:12 powerpeng

hey, can you paste a code snippet that crashes? i will take a look into it thx

r-lyeh-archived avatar Dec 28 '15 09:12 r-lyeh-archived

hey, my crash code like this , may be it is logic unreasonable , but your attention is to delete all aborted elements in function command , crash message : deque iterator not decrementable cd_player cd; cd.fsm.push(fsm::state(play)); cd.fsm.push(fsm::state(open)); cd.fsm.command(close);

powerpeng avatar Dec 29 '15 06:12 powerpeng

forgive my poor english !

powerpeng avatar Dec 29 '15 06:12 powerpeng

in order to avoid error , i try to change code like this : // user commands bool command(const fsm::state &trigger) { size_t size = this->size(); if (!size) { return false; } current_trigger = fsm::state(); std::deque< states::iterator > aborted; for (auto it = deque.rbegin(); it != deque.rend(); ++it) { fsm::state &self = _it; if (!call(self, trigger)) { aborted.push_back(it.base() - 1); continue; } for (auto it = aborted.begin(), end = aborted.end(); it != end; ++it) { call(__it, 'quit'); deque.erase(_it); } current_trigger = trigger; return true; } return false; }

powerpeng avatar Dec 29 '15 06:12 powerpeng

@powerpeng

your code can`t build

shafeng avatar Jan 08 '16 12:01 shafeng

@shafeng , i builded the code and it works , would you paste the error message please .

powerpeng avatar Jan 11 '16 13:01 powerpeng

@powerpeng sorry , maybe my C++ compiler without C++11 support

shafeng avatar Jul 19 '18 10:07 shafeng