我写了一个运行
的程序1和3是两个不同的实例,可以重叠。
给出麻烦的功能的签名。
bool ProcessInfoHandler::getCPUInfo (rsc::ProcInfo &procInfo, bool isThreadCall)
运行程序大约3天后,我得到了下面提到的崩溃。
#2 0x000000000041fdb8 in sn_sig_handler (signum=6, siginfo=0x451a7d80, undocumented= <value optimized out>) at common/main/sn_proc_main.cpp:109
#3 <signal handler called>
#4 0x00000031d9630265 in raise () from /lib64/libc.so.6
#5 0x00000031d9631d10 in abort () from /lib64/libc.so.6
#6 0x00000031d966a84b in __libc_message () from /lib64/libc.so.6
#7 0x00000031d967230f in _int_free () from /lib64/libc.so.6
#8 0x00000031d967276b in free () from /lib64/libc.so.6
#9 0x00000000004367a5 in deallocate (this=0x66cff0, __position=..., __x=<value optimized out>)
at /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h:94
#10 _M_deallocate (this=0x66cff0, __position=..., __x=<value optimized out>) at /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:133
#11 std::vector<cpu_instance_data_t, std::allocator<cpu_instance_data_t> >::_M_insert_aux (this=0x66cff0, __position=..., __x=<value optimized out>)
at /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/vector.tcc:299
#12 0x0000000000431f8e in ProcessInfoHandler::getCPUInfo (this=<value optimized out>, procInfo=..., isThreadCall=false)
at /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:610
#13 0x00000000004333be in ProcessInfoHandler::getProcessInformation (this=0xc16f9c0, procInfoSeq=..., isThreadCall=false) at processinfohandler.cc:255
由于专有原因,无法提供getCPUInfo
的代码。请建议是否有相同的解决方法。
答案 0 :(得分:2)
对std::vector<>::_M_insert_aux()
的调用表明正在getCPUInfo
中修改向量 - 如果此代码可以同时调用(在多个线程上),这是“3列表”所暗示的,那么你需要有一些诸如互斥的东西来同步线程。
std::vector
不是线程安全的。