0
class MyClass{
public :
void runBscGwThread(int);
private :
std::unique_ptr<std::thread> MyClass_;
}
MyClass::Myclass(int bcfId, A::AParam sctpParams):
bcfId_(bcfId),
{
Myclass_.reset(new std::thread([this](){ this->runBscGwThread(bcfId_);}));
}
偶爾會看到此問題。在析構函數中我做SIGABRT問題在valgrind中用C++中的多線程處理11
Myclass:: ~Myclass(){
if (Myclass_->joinable)
Myclass_->join();
}
的Valgrind的日誌低於:
fatal_signal>
<tid>2</tid>
<signo>6</signo>
<signame>SIGABRT</signame>
<sicode>-6</sicode>
<stack>
<frame>
<ip>0x670DB80</ip
/編譯/ ltesdkroot /數據/平臺/ IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/OS/SYS-根/ i686的-PC-Linux的GNU/usr/lib目錄/ libc-2.24.so
<fn>raise</fn>
</frame>
<frame>
<ip>0x670F046</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libc-2.24.so</obj>
<fn>abort</fn>
</frame>
<frame>
<ip>0x656831E</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libstdc++.so.6.0.22</obj>
<fn>__gnu_cxx::__verbose_terminate_handler()</fn>
</frame>
<frame>
<ip>0x6565EC3</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libstdc++.so.6.0.22</obj>
</frame>
<frame>
<ip>0x6564C28</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libstdc++.so.6.0.22</obj>
</frame>
<frame>
<ip>0x6565426</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libstdc++.so.6.0.22</obj>
<fn>__gxx_personality_v0</fn>
</frame>
<frame>
<ip>0x66D941E</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libgcc_s.so.1</obj>
</frame>
<frame>
<ip>0x66D974C</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libgcc_s.so.1</obj>
<fn>_Unwind_RaiseException</fn>
</frame>
<frame>
<ip>0x65661E3</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libstdc++.so.6.0.22</obj>
<fn>__cxa_throw</fn>
</frame>
<frame>
<ip>0x65913F2</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libstdc++.so.6.0.22</obj>
<fn>std::__throw_system_error(int)</fn>
</frame>
<frame>
<ip>0x6593917</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libstdc++.so.6.0.22</obj>
<fn>std::thread::join()</fn>
</frame>
<frame>
<ip>0x8083F41</ip>
<obj>/dev/shm/workspace/GTS+trunk.x86.VALGRIND.UT/build/x86/gts/test/ut/tests/BscGw/GTS-BscGw-UT</obj>
<fn>GTS::BSCGW::Myclass::stop()</fn>
</frame>
<frame>
<ip>0x8083F69</ip>
<obj>/dev/shm/workspace/GTS+trunk.x86.VALGRIND.UT/build/x86/gts/test/ut/tests/BscGw/GTS-BscGw-UT</obj>
<fn>GTS::BSCGW::Myclass::~Myclass()</fn>
</frame>
<frame>
<ip>0x807DD62</ip>
<obj>/dev/shm/workspace/GTS+trunk.x86.VALGRIND.UT/build/x86/gts/test/ut/tests/BscGw/GTS-BscGw-UT</obj>
<fn>std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count()</fn>
</frame>
<frame>
<ip>0x807E15E</ip>
<obj>/dev/shm/workspace/GTS+trunk.x86.VALGRIND.UT/build/x86/gts/test/ut/tests/BscGw/GTS-BscGw-UT</obj>
<fn>std::_Rb_tree<int, std::pair<int const, std::pair<std::shared_ptr<, std::shared_ptr<GTS::BSCGW::Myclass> > >, std::_Select1st<std::pair<int const, std::pair<, std::shared_ptr<GTS::BSCGW::Myclass> > > >, std::less<int>, std::allocator<std::pair<int const, std::pair<std::shared_ptr<, std::shared_ptr<GTS::BSCGW::Myclass> > > > >::_M_erase(std::_Rb_tree_node<std::pair<int const, std::pair<std::shared_ptr< std::shared_ptr<GTS::BSCGW::Myclass> > > >*)</fn>
</frame>
<frame>
<ip>0x807E150</ip>
<obj>/dev/shm/workspace/GTS+trunk.x86.VALGRIND.UT/build/x86/gts/test/ut/tests/BscGw/GTS-BscGw-UT</obj>
<fn>std::_Rb_tree<int, std::pair<int const, std::pair<std::shared_ptr<, std::shared_ptr<GTS::BSCGW::Myclass> > >, std::_Select1st<std::pair<int const, std::pair<std::shared_ptr<, std::shared_ptr<GTS::BSCGW::Myclass> > > >, std::less<int>, std::allocator<std::pair<int const, std::pair<std::shared_ptr<, std::shared_ptr<GTS::BSCGW::Myclass> > > > >::_M_erase(std::_Rb_tree_node<std::pair<int const, std::shared_ptr<GTS::BSCGW::Myclass> > > >*)</fn>
</frame>
<frame>
<ip>0x8084928</ip>
<obj>/dev/shm/workspace/GTS+trunk.x86.VALGRIND.UT/build/x86/gts/test/ut/tests/BscGw/GTS-BscGw-UT</obj>
<fn>GTS::BSCGW::Myclass::readFromSocket(std::vector<unsigned char, std::allocator<unsigned char> >&, int)</fn>
</frame>
<frame>
<ip>0x8085142</ip>
<obj>/dev/shm/workspace/GTS+trunk.x86.VALGRIND.UT/build/x86/gts/test/ut/tests/BscGw/GTS-BscGw-UT</obj>
<fn>GTS::BSCGW::Myclass::runBscGwThread(int)</fn>
</frame>
<frame>
<ip>0x80852A6</ip>
<obj>/dev/shm/workspace/GTS+trunk.x86.VALGRIND.UT/build/x86/gts/test/ut/tests/BscGw/GTS-BscGw-UT</obj>
<fn>std::thread::_Impl<std::_Bind_simple<GTS::BSCGW::Myclass::Myclass(int, GTS::AbisSctpParam)::{lambda()#1}()> >::_M_run()</fn>
</frame>
<frame>
<ip>0x6593A8D</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libstdc++.so.6.0.22</obj>
</frame>
<frame>
<ip>0x64DD2E9</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libpthread-2.24.so</obj>
<fn>start_thread</fn>
</frame>
<frame>
<ip>0x67C90ED</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libc-2.24.so</obj>
<fn>clone</fn>
</frame>
堆棧跟蹤似乎表明您正在銷燬'MyClass :: runBscGwThread'中的'MyClass',所以這個線程試圖加入它自己。這正確地拋出'system_error' –