map operator[] 一个段错误,还未看出bug所在
以下是gdb的backtrace:
#0 0x08050a9f in std::_Rb_tree<Event, std::pair<Event const, std::list<Action*, std::allocator<Action*> > >, std::_Select1st<std::pair<Event const, std::list<Action*, std::allocator<Action*> > > >, std::less<Event>, std::allocator<std::pair<Event const, std::list<Action*, std::allocator<Action*> > > > >::insert_unique (
this=0x8066fc4, __position=
{<std::_Rb_tree_base_iterator> = {_M_node = 0x8066868}, <No data fields>},__v=@0xbfff73e0) at stl_tree.h:1063
1063 if (__position._M_node == _M_header->_M_left)
~~~~~~~~~~这里发生段错误。_M_left野指针
(gdb) bt
#0 0x08050a9f in std::_Rb_tree<Event, std::pair<Event const, std::list<Action*, std::allocator<Action*> > >, std::_Select1st<std::pair<Event const, std::list<Action*, std::allocator<Action*> > > >, std::less<Event>, std::allocator<std::pair<Event const, std::list<Action*, std::allocator<Action*> > > > >::insert_unique (
this=0x8066fc4, __position=
{<std::_Rb_tree_base_iterator> = {_M_node = 0x8066868}, <No data fields>},__v=@0xbfff73e0) at stl_tree.h:1063
#1 0x08050227 in std::map<Event, std::list<Action*, std::allocator<Action*> >, std::less<Event>, std::allocator<std::pair<Event const, std::list<Action*, std::allocator<Action*> > > > >::insert (this=0x8066fc4, position=
{<std::_Rb_tree_base_iterator> = {_M_node = 0x0}, <No data fields>},
__x=@0xbfff73e0) at stl_map.h:364
#2 0x0804fef0 in std::map<Event, std::list<Action*, std::allocator<Action*> >, std::less<Event>, std::allocator<std::pair<Event const, std::list<Action*, std::allocator<Action*> > > > >::operator[] (this=0x8066fc4, __k=@0xbfff7620)
at stl_map.h:319
#3 0x0804fb19 in Status::AddRule (this=0x8066fc4, newEvent=@0xbfff7620,
newActions=@0xbfff75d0, toState=0x8066fe4) at Proto/Status.cpp:49
在这里执行:actRules[newEvent] = newActions;
actRules类型map< Event, list<Action*> >
搞不清楚什么原因。
大家帮忙看看,谢谢!