map operator[] 一个段错误,还未看出bug所在

muddogxp 2005-10-18 10:03:30
以下是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*> >

搞不清楚什么原因。
大家帮忙看看,谢谢!

...全文
259 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaonian_3654 2005-10-19
  • 打赏
  • 举报
回复
交个朋友

msn: ZZZZzzzz4@hotmail.com
muddogxp 2005-10-19
  • 打赏
  • 举报
回复
恩,现在改用string。当初是为了考虑跑的时候的效率
拷贝构造, operator=之类写了一大堆,就是为了char*
xiaonian_3654 2005-10-19
  • 打赏
  • 举报
回复
楼主贴得是gdb调试的时候的栈回溯阿

std::string有源代码阿
muddogxp 2005-10-18
  • 打赏
  • 举报
回复
总算查到了!strcpy溢出了。。。。
K 2005-10-18
  • 打赏
  • 举报
回复
给源码阿
foochow 2005-10-18
  • 打赏
  • 举报
回复
晕,楼主帖的是什么
muddogxp 2005-10-18
  • 打赏
  • 举报
回复
帮忙看看哦,蛮急的!
xlsue 2005-10-18
  • 打赏
  • 举报
回复
支持楼上的,但又不见源码。。。
muddogxp 2005-10-18
  • 打赏
  • 举报
回复
而且要插入的pair对<Event, list<Action*> >也无异常。
xiaonian_3654 2005-10-18
  • 打赏
  • 举报
回复
strcpy会溢出吗?
====================
当然会!

楼主,你既然用STL就不要用strcpy
用std::string多好啊
fiftymetre 2005-10-18
  • 打赏
  • 举报
回复
回复人: muddogxp(土狗) ( ) 信誉:98 2005-10-18 11:44:00 得分: 0


总算查到了!strcpy溢出了。。。。



strcpy会溢出吗?
oyljerry 2005-10-18
  • 打赏
  • 举报
回复
代码看着好花
hslinux 2005-10-18
  • 打赏
  • 举报
回复
晕。。。。。。

64,646

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧