- 论坛徽章:
- 0
|
我有一个程序在运行时需要初始化一个map,但程序却在map的第一个赋值处阻塞,很不解,下面是调试过程。
比如该程序的进程号为12345
#strace -p 12345
Process 23524 attached - interrupt to quit
只返回这一行结果。
又通过gdb attach到该进程得到如下结果:
- (gdb) attach 12345
- ... (中间省略了,只输出最后一句)
- 0x08072787 in std::less<int>::operator() (this=0x80a1f44, __x=@0x80a1f54, __y=@0xbfae9d44)
- at /usr/lib/gcc/i386-redhat-linux/4.1.0/../../../../include/c++/4.1.0/bits/stl_function.h:227
- 227 { return __x < __y; }
- (gdb) bt
- #0 0x08072787 in std::less<int>::operator() (this=0x80a1f44, __x=@0x80a1f54, __y=@0xbfae9d44)
- at /usr/lib/gcc/i386-redhat-linux/4.1.0/../../../../include/c++/4.1.0/bits/stl_function.h:227
- #1 0x080738bf in std::_Rb_tree<int, std::pair<int const, std::string>, std::_Select1st<std::pair<int const, std::string> >, std::less<int>, std::allocator<std::pair<int const, std::string> > >::lower_bound (this=0x80a1f44, __k=@0xbfae9d44)
- at /usr/lib/gcc/i386-redhat-linux/4.1.0/../../../../include/c++/4.1.0/bits/stl_tree.h:1371
- #2 0x0807392d in std::map<int, std::string, std::less<int>, std::allocator<std::pair<int const, std::string> > >::lower_bound (this=0x80a1f44, __x=@0xbfae9d44) at /usr/lib/gcc/i386-redhat-linux/4.1.0/../../../../include/c++/4.1.0/bits/stl_map.h:576
- #3 0x08074da0 in std::map<int, std::string, std::less<int>, std::allocator<std::pair<int const, std::string> > >::operator[] (this=0x80a1f44, __k=@0xbfae9d44) at /usr/lib/gcc/i386-redhat-linux/4.1.0/../../../../include/c++/4.1.0/bits/stl_map.h:345
- #4 0x080686f2 in Student::initIdName (this=0x80a1e40) at Student.cpp:213
- #5 0x0806598c in main (argc=2, argv=0xbfae9ee4) at Main.cpp:56
- 确定了最终阻塞的位置是:
- stl_function.h文件中:
- template <class _Tp>
- struct less : public binary_function<_Tp, _Tp, bool>
- {
- bool
- operator()(const _Tp& __x, const _Tp& __y) const
- { return __x < __y; } // <=======阻塞在这行
- };
复制代码
我map的键从一个比较大的数开始,比如8000,我想跟这个应该没关系吧。没读过map的实现源码,不敢定论,抽时间看一下。
因为我这个程序编译的时候连接了一些动态库和静态库,会不会在静态库重新编译后,我的.o文件有的重新连接而有的没重新连接使得影响了一些变量的地址,但为什么会在一个比较语句处阻塞呢? |
|