免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2028 | 回复: 3
打印 上一主题 下一主题

[C++] 请教一个gdb 抓获的错误 找不到屏蔽的方法 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-03-26 18:28 |只看该作者 |倒序浏览
本帖最后由 skybyte 于 2013-03-26 18:38 编辑

请教一个gdb 抓获的错误 找不到屏蔽的方法 在哪里增加检查才能避免出错呢。
  1. #0  0x000000000082007d in std::__niter_base<__gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char> > >, true>:: (__it=...) at /usr/include/c++/4.4/bits/stl_algobase.h:278
  2. #1  0x000000000081fba0 in std::__copy_move_a2<false, __gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char> > >, unsigned char*> (__first=..., __last=..., __result=0x7fe5b96f4090 "") at /usr/include/c++/4.4/bits/stl_algobase.h:436
  3. #2  0x000000000081f1c7 in std::copy<__gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char> > >, unsigned char*> (__first=..., __last=..., __result=0x7fe5b96f4090 "") at /usr/include/c++/4.4/bits/stl_algobase.h:468
  4. #3  0x000000000081cec2 in std::__uninitialized_copy<true>::uninitialized_copy<__gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char> > >, unsigned char*> (__first=..., __last=..., __result=0x7fe5b96f4090 "") at /usr/include/c++/4.4/bits/stl_uninitialized.h:93
  5. #4  0x000000000081b035 in std::uninitialized_copy<__gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char> > >, unsigned char*> (__first=..., __last=..., __result=0x7fe5b96f4090 "") at /usr/include/c++/4.4/bits/stl_uninitialized.h:117
  6. #5  0x0000000000819d54 in std::__uninitialized_copy_a<__gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char> > >, unsigned char*, unsigned char> (__first=..., __last=..., __result=0x7fe5b96f4090 "") at /usr/include/c++/4.4/bits/stl_uninitialized.h:257
  7. #6  0x000000000081891d in std::vector<unsigned char, std::allocator<unsigned char> >::vector (this=0x7fe5a91479b0, __x=...)
  8.     at /usr/include/c++/4.4/bits/stl_vector.h:243
  9. #7  0x0000000000a59261 in ByteBuffer::ByteBuffer (this=0x7fe5a91479a0, buf=...) at shared/ByteBuffer.h:72
  10. #8  0x0000000000a59427 in WorldPacket::WorldPacket (this=0x7fe5a91479a0, packet=...) at shared/WorldPacket.h:37
  11. #9  0x0000000000a562d7 in WorldSocket::SendPacket (this=0x7fe5da263d80, pct=...) at game/WorldSocket.cpp:149

  12. WorldSocket.cpp:149 这行的上下文是

  13.     if (iSendPacket (pct) == -1)
  14.     {
  15.         WorldPacket* npct;

  16.         ACE_NEW_RETURN (npct, WorldPacket (pct), -1);   //这是149行

  17.         // NOTE maybe check of the size of the queue can be good ?
  18.         // to make it bounded instead of unbounded
  19.         if (m_PacketQueue.enqueue_tail (npct) == -1)
  20.         {
  21.             delete npct;
  22.             sLog.outError ("WorldSocket::SendPacket: m_PacketQueue.enqueue_tail failed");
  23.             return -1;
  24.         }
  25.     }




  26. shared/WorldPacket.h:37 的上下文是


  27. class WorldPacket : public ByteBuffer
  28. {
  29.     public:
  30.                                                             // just container for later use
  31.         WorldPacket()                                       : ByteBuffer(0), m_opcode(0)
  32.         {
  33.         }
  34.         explicit WorldPacket(uint16 opcode, size_t res=200) : ByteBuffer(res), m_opcode(opcode) { }
  35.                                                             // copy constructor
  36. /*         下面这行是37行 */
  37.         WorldPacket(const WorldPacket &packet)              : ByteBuffer(packet), m_opcode(packet.m_opcode)//37行
  38.         {
  39.         }

  40.         void Initialize(uint16 opcode, size_t newres=200)
  41.         {
  42.             clear();
  43.             _storage.reserve(newres);
  44.             m_opcode = opcode;
  45.         }

  46.         uint16 GetOpcode() const { return m_opcode; }
  47.         void SetOpcode(uint16 opcode) { m_opcode = opcode; }

  48.     protected:
  49.         uint16 m_opcode;
  50. };
  51. #endif



  52. shared/ByteBuffer.h:72  的上下文是

  53.         // constructor
  54.         ByteBuffer(): _rpos(0), _wpos(0)
  55.         {
  56.             _storage.reserve(DEFAULT_SIZE);
  57.         }

  58.         // constructor
  59.         ByteBuffer(size_t res): _rpos(0), _wpos(0)
  60.         {
  61.             _storage.reserve(res);
  62.         }

  63.         // copy constructor
  64.         ByteBuffer(const ByteBuffer &buf): _rpos(buf._rpos), _wpos(buf._wpos), _storage(buf._storage) { } //72行



复制代码

论坛徽章:
4
水瓶座
日期:2013-09-06 12:27:30摩羯座
日期:2013-09-28 14:07:46处女座
日期:2013-10-24 14:25:01酉鸡
日期:2014-04-07 11:54:15
2 [报告]
发表于 2013-03-26 18:34 |只看该作者
valgrind试试看

论坛徽章:
0
3 [报告]
发表于 2013-03-26 18:42 |只看该作者
本帖最后由 skybyte 于 2013-03-26 18:42 编辑

看起来就是发包的时候出错了

但出错系统就坏了,这个怎么办呢

    if (iSendPacket (pct) == -1)
    {
        WorldPacket* npct;

        ACE_NEW_RETURN (npct, WorldPacket (pct), -1);   //这是149行  从这里下去开始死掉

        // NOTE maybe check of the size of the queue can be good ?
        // to make it bounded instead of unbounded
        if (m_PacketQueue.enqueue_tail (npct) == -1)
        {
            delete npct;
            sLog.outError ("WorldSocket::SendPacket: m_PacketQueue.enqueue_tail failed");
            return -1;
        }
    }

论坛徽章:
0
4 [报告]
发表于 2013-03-26 18:49 |只看该作者
本帖最后由 skybyte 于 2013-03-26 21:27 编辑

GDB虽然强大,看得也是头晕,还没找到解决办法
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP