【发布时间】:2011-03-03 20:39:13
【问题描述】:
我在应用程序中使用 hash_map 作为
typedef hash_map<DWORD,CComPtr<IInterfaceXX>> MapDword2Interface;
在主应用程序中,我正在使用此地图的静态实例
static MapDword2Interface m_mapDword2Interface;
我从其中一台客户端机器获得了一个故障转储,它指向清除此地图时发生的崩溃
我打开了那个故障转储,这里是调试期间的程序集
> call std::list<std::pair<unsigned long const ,ATL::CComPtr<IInterfaceXX> >,std::allocator<std::pair<unsigned long const ,ATL::CComPtr<IInterfaceXX> > > >::clear
> mov eax,dword ptr [CMainApp::m_mapDword2Interface+8 (49XXXXX)]
这是故障转储指向的代码。下面的代码来自 stl:list 文件
void clear()
{ // erase all
#if _HAS_ITERATOR_DEBUGGING
this->_Orphan_ptr(*this, 0);
#endif /* _HAS_ITERATOR_DEBUGGING */
_Nodeptr _Pnext;
_Nodeptr _Pnode = _Nextnode(_Myhead);
_Nextnode(_Myhead) = _Myhead;
_Prevnode(_Myhead) = _Myhead;
_Mysize = 0;
for (; _Pnode != _Myhead; _Pnode = _Pnext)
{ // delete an element
_Pnext = _Nextnode(_Pnode);
this->_Alnod.destroy(_Pnode);
this->_Alnod.deallocate(_Pnode, 1);
}
}
Crash 指向的是this->_Alnod.destroy(_Pnode);上面代码中的语句。
我猜不出来,可能是什么原因。
有什么想法吗???
我怎样才能确保,即使地图有问题,它也不应该崩溃?
【问题讨论】:
标签: visual-c++ stl crash hashmap atl