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應該也可以.