0
我在我的代碼,一個奇怪的分段錯誤,其使用下面的數據結構:STL集合內部地圖,怪異賽格故障和Valgrind的分析
map< uint64_t, set<uint64_t> > _key_to_block;
Valgrind的的_key_to_block.erase(it)
抱怨此消息:
Address 0x6106118 is 56 bytes inside a block of size 88 free'd
用於從地圖擦除元素,如下所示:
map< uint64_t, set<uint64_t> >::iterator it = _key_to_block.find(key);
(it->second).clear();
_key_to_block.erase(it);
此外,Valgrind也compl與此按摩的(it->second).insert(k);
AINS:
Invalid read of size 8
像這樣在STL組插入元件:
map< uint64_t, set<uint64_t> >::iterator it = _key_to_block.find(key);
(it->second).insert(value);
然而,它並沒有抱怨這一行的:
setit = it->second.find(value);
不限想法?
你確定你的地圖存在'_key_to_block'嗎?而且你沒有在某個地方破壞它的記憶?你可以發佈你的測試用具嗎? – 2013-02-11 00:37:33