- 论坛徽章:
- 0
|
本帖最后由 redboy333 于 2012-10-22 15:03 编辑
有段程序跑了大概2小时coredump了。
程序里是用了这样的结构 std::map<std::string,std::string> m_testmap
在一个函数中做了拷贝 m_testmap = testmap
看堆栈是
(gdb) bt
#0 0xffffe410 in __kernel_vsyscall ()
#1 0xf5fb0a30 in raise () from /lib/libc.so.6
#2 0xf5fb2153 in abort () from /lib/libc.so.6
#3 0xf5fe608b in __libc_message () from /lib/libc.so.6
#4 0xf5feba51 in malloc_printerr () from /lib/libc.so.6
#5 0xf5fed224 in free () from /lib/libc.so.6
#6 0xf61ab2b1 in operator delete () from /usr/lib/libstdc++.so.6
#7 0xf618816d in std::string::_Rep::_M_destroy () from /usr/lib/libstdc++.so.6
#8 0xf618acf7 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string ()
from /usr/lib/libstdc++.so.6
#9 0xf774972a in ~pair (this=0x9f956f2 at /usr/include/c++/4.1.2/bits/stl_pair.h:69
#10 0xf7749775 in __gnu_cxx::new_allocator<std::pair<std::string const, std::string> >::destroy (this=0xad2daf7f, __p=0x9f956f2
at /usr/include/c++/4.1.2/ext/new_allocator.h:107
#11 0xf7749871 in std::_Rb_tree<std::string, std::pair<std::string const, std::string>, std::_Select1st<std::pair<std::string const, std::string> >, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >::destroy_node (
this=0x81da43c, __p=0x9f956f1 at /usr/include/c++/4.1.2/bits/stl_tree.h:391
#12 0xf7749904 in std::_Rb_tree<std::string, std::pair<std::string const, std::string>, std::_Select1st<std::pair<std::string const, std::string> >, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >::_M_erase (
this=0x81da43c, __x=0x9f956f1 at /usr/include/c++/4.1.2/bits/stl_tree.h:1266
#13 0xf77499d3 in std::_Rb_tree<std::string, std::pair<std::string const, std::string>, std::_Select1st<std::pair<std::string const, std::string> >, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >::clear (this=0x81da43c)
at /usr/include/c++/4.1.2/bits/stl_tree.h:692
#14 0xf6b34783 in std::_Rb_tree<std::string, std::pair<std::string const, std::string>, std::_Select1st<std::pair<std::string const, std::string> >, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >: perator= (
this=0x81da43c, __x=@0xad2db0a at /usr/include/c++/4.1.2/bits/stl_tree.h:796
#15 0xf6b34858 in std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >: perator= (this=0x81da43c, __x=@0xad2db0a at /usr/include/c++/4.1.2/bits/stl_map.h:227
#16 0xf6b3205a in CmapInfo::setMap (this=0x81d9688, TokenCodeMap=@0xad2db0a
|
而此时拷贝过去的map的值是
(gdb) pmap tmpMap 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >' 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >'
elem[0].left: $3 = {
static npos = 4294967295,
_M_dataplus = {
<std::allocator<char>> = {
<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
members of std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Alloc_hider:
_M_p = 0x98f74484 "source1"
}
}
elem[0].right: $4 = {
static npos = 4294967295,
_M_dataplus = {
<std::allocator<char>> = {
<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
members of std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Alloc_hider:
_M_p = 0xf61db5dc ""
}
}
Map size = 1
|
想问问各位到底是啥原因?这里的map难道不能这样map<"xxxx","">?这里是空字符串,又不是NULL。搞不懂了? |
|