std::map<char*, GhRecord*>::iterator funcIter = g_oRecordFunctionMap.begin(); while (funcIter != g_oFunctionMap.end()) { GhRecord* pFuncRecord = funcIter->second; funcIter++; ... }
出错的位置都是funcIter++处.有两种情形:
- 卡死.
- 崩溃.错误也是很奇怪:
#0 0x00007fcf790ff458 in std::less<char*>::operator() ( this=0x7fcf79302420 <g_oRecordFunctionMap>, __x=@0xf8: <error reading variable>, __y=@0x7fcf45199060: 0x7fcf28042400 "tcpclient.c-tcpclient_recv-71") at /usr/include/c++/5/bits/stl_function.h:387 387 { return __x < __y; } 或者 _Rb_tree_increment(std::_Rb_tree_node_base const*) () from /usr/lib
难道吾使用方式不对?吾反复核查,都没有发现问题.
后来输出funcIter->first,发现是乱码.嗯?于是把KEY改成malloc()的,不再出错了.
当然,改用std:;string应该也可以.