当前位置: 技术问答>linux和unix
LINUX 下使用 MAP,执行时报错,求助,
来源: 互联网 发布时间:2017-05-11
本文导语: typedef unsigned long DWORD; typedef struct _tagStructPlatformService { DWORD dwId; DWORD dwFunctionId; DWORD dwCount; }StructPlatformService; typedef map CMapPlatformService; StructPlatformService *pStructPlatformService = new StructPlatformService; pStr...
typedef unsigned long DWORD;
typedef struct _tagStructPlatformService
{
DWORD dwId;
DWORD dwFunctionId;
DWORD dwCount;
}StructPlatformService;
typedef map CMapPlatformService;
StructPlatformService *pStructPlatformService = new StructPlatformService;
pStructPlatformService->dwId=atoi(pData[0]);
pStructPlatformService->dwFunctionId=atoi(pData[1]);
pStructPlatformService->dwCount =atoi(pData[2]);
DWORD nKey=pStructPlatformService->dwId;
CMapPlatformService::iterator itr=m_pStructDatabaseMapManage->mapPlatformService.find(nKey);
在执行到find(nKey)程序就崩溃了,
bt内容如下:
(gdb) bt
#0 0x08058166 in std::less::operator() (this=0x8122ad0, __x=@0xb8000010, __y=@0xb6e16ba8)
at /usr/lib/gcc/i686-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/stl_function.h:230
#1 0x08059025 in std::_Rb_tree::_M_lower_bound (this=0x8122ad0, __x=0xb8000000, __y=0x8122ad4, __k=@0xb6e16ba8)
at /usr/lib/gcc/i686-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/stl_tree.h:986
#2 0x08057f10 in std::_Rb_tree::find (this=0x8122ad0, __k=@0xb6e16ba8)
at /usr/lib/gcc/i686-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/stl_tree.h:1421
#3 0x0805705a in std::map::find (this=0x8122ad0, __x=@0xb6e16ba8)
at /usr/lib/gcc/i686-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/stl_map.h:659
程序在写完后一直没有问题,突然有一天执行,就崩溃了。
还有在未初初化的情况下执行:
m_StructDatabaseMapManage.mapPlatformService.clear();
也会崩溃。
研究了好久都没有解决。向大大们求助了。
typedef struct _tagStructPlatformService
{
DWORD dwId;
DWORD dwFunctionId;
DWORD dwCount;
}StructPlatformService;
typedef map CMapPlatformService;
StructPlatformService *pStructPlatformService = new StructPlatformService;
pStructPlatformService->dwId=atoi(pData[0]);
pStructPlatformService->dwFunctionId=atoi(pData[1]);
pStructPlatformService->dwCount =atoi(pData[2]);
DWORD nKey=pStructPlatformService->dwId;
CMapPlatformService::iterator itr=m_pStructDatabaseMapManage->mapPlatformService.find(nKey);
在执行到find(nKey)程序就崩溃了,
bt内容如下:
(gdb) bt
#0 0x08058166 in std::less::operator() (this=0x8122ad0, __x=@0xb8000010, __y=@0xb6e16ba8)
at /usr/lib/gcc/i686-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/stl_function.h:230
#1 0x08059025 in std::_Rb_tree::_M_lower_bound (this=0x8122ad0, __x=0xb8000000, __y=0x8122ad4, __k=@0xb6e16ba8)
at /usr/lib/gcc/i686-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/stl_tree.h:986
#2 0x08057f10 in std::_Rb_tree::find (this=0x8122ad0, __k=@0xb6e16ba8)
at /usr/lib/gcc/i686-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/stl_tree.h:1421
#3 0x0805705a in std::map::find (this=0x8122ad0, __x=@0xb6e16ba8)
at /usr/lib/gcc/i686-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/stl_map.h:659
程序在写完后一直没有问题,突然有一天执行,就崩溃了。
还有在未初初化的情况下执行:
m_StructDatabaseMapManage.mapPlatformService.clear();
也会崩溃。
研究了好久都没有解决。向大大们求助了。
|
代码没看出什么问题,如果运行了一段时间后才出错的话,也可能是其它地方引起的,比如在同一个栈内的数组越界,破坏了mapPlatformService的内存。
还有在未初初化的情况下执行:
m_StructDatabaseMapManage.mapPlatformService.clear();
也会崩溃。
建议另建立一个小的测试工程,看看是否也会崩溃,然后再比较正式项目的写法。
还有在未初初化的情况下执行:
m_StructDatabaseMapManage.mapPlatformService.clear();
也会崩溃。
建议另建立一个小的测试工程,看看是否也会崩溃,然后再比较正式项目的写法。
|
最重要的堆栈信息是最后几个,你给了最上面的几个,木用。
m_pStructDatabaseMapManage为空否?
mapPlatformService合法否?
m_pStructDatabaseMapManage为空否?
mapPlatformService合法否?