我有一個自定義庫,我正在測試。我有單元測試和組件測試。單元測試使用與組件測試相同的代碼。主要區別是組件測試必須啓動一個單獨的線程來運行我的庫代碼。當它這樣做時,我開始看到下面突出顯示的崩潰。有幾點需要注意:涉及boost :: thread的奇怪崩潰
- 我鏈接agaisnt libboost_system,libboost_thread,並行線程,室溫等
- 同樣的調用堆棧在單元測試沒有問題行使。
- 我檢查確保沒有* -mt版本的boost線程。我確信,我所鏈接的那個線程支持。
- 在Linux主機上不會發生崩潰。只有freebsd。
- 我檢查堆棧溢出。下面的上下文在第一幀和最後一幀之間使用大約42KB的堆棧空間。我爲我生成的提升線程顯式設置堆棧大小爲1MB。
我很新鮮的想法。任何建議,將不勝感激。
Program terminated with signal 11, Segmentation fault.
#0 strcat() at /usr/src/lib/libc/i386/string/strcat.S:50
50 pushl %edi /* save edi */
(gdb) bt
#0 strcat() at /usr/src/lib/libc/i386/string/strcat.S:50
#1 0x2831f603 in tzload (name=0x2834baa0 "UTC", sp=0x283644a0, doextend=1) at /usr/src/lib/libc/stdtime/localtime.c:427
#2 0x2831fe6f in gmtload (sp=0x0) at /usr/src/lib/libc/stdtime/localtime.c:1203
#3 0x2831fea6 in gmt_init() at /usr/src/lib/libc/stdtime/localtime.c:1477
#4 0x28138f60 in _pthread_once (once_control=0x28361560, init_routine=0x2831fe89 <gmt_init at /usr/src/lib/libc/stdtime/localtime.c:1471>)
at /usr/src/lib/libthr/thread/thr_once.c:87
#5 0x28323590 in _once (once_control=0x28361560, init_routine=0x2831fe89 <gmt_init at /usr/src/lib/libc/stdtime/localtime.c:1471>)
at /usr/src/lib/libc/gen/_once_stub.c:62
#6 0x2831ecb1 in gmtsub (timep=0xbf7fcca4, offset=0, tmp=0xbf7fcc6c) at /usr/src/lib/libc/stdtime/localtime.c:1492
#7 0x2831ed3c in gmtime_r (timep=0xbf7fcca4, tmp=0xbf7fcc6c) at /usr/src/lib/libc/stdtime/localtime.c:1564
#8 0x080ab51b in boost::date_time::c_time::gmtime (t=0xbf7fcca4, result=0xbf7fcc6c) at ../../../contrib/opensource/boost/boost/date_time/c_time.hpp:85
#9 0x080ac4da in boost::asio::time_traits<boost::posix_time::ptime>::now()()
#10 0x080a7f99 in expires_from_now (this=0x81181b0) at ../../../contrib/opensource/boost/boost/asio/detail/deadline_timer_service.hpp:155
#11 expires_from_now (this=0x81181b0) at ../../../contrib/opensource/boost/boost/asio/deadline_timer_service.hpp:124
#12 expires_from_now (this=0x81181b0) at ../../../contrib/opensource/boost/boost/asio/basic_deadline_timer.hpp:410
#13 smf::service::Manager::arm_degraded_services_timer (this=0x81181b0) at Manager.cpp:247
#14 0x080a8747 in smf::service::Manager::defer_degraded_service (this=0x81181b0, service=0x825c140) at Manager.cpp:269
#15 0x080a8948 in smf::service::Manager::service_signal_handler (this=0x81181b0, error_code=..., signal_number=20) at Manager.cpp:203
#16 0x080aa267 in operator() (owner=0x8123060, base=0x82567c0) at ../../../contrib/opensource/boost/boost/bind/mem_fn_template.hpp:280
#17 operator()<boost::_mfi::mf2<void, smf::service::Manager, const boost::system::error_code&, int>, boost::_bi::list2<const boost::system::error_code&, const int&> > (owner=0x8123060, base=0x82567c0) at ../../../contrib/opensource/boost/boost/bind/bind.hpp:392
#18 operator()<boost::system::error_code, int> (owner=0x8123060, base=0x82567c0) at ../../../contrib/opensource/boost/boost/bind/bind_template.hpp:102
#19 operator() (owner=0x8123060, base=0x82567c0) at ../../../contrib/opensource/boost/boost/asio/detail/bind_handler.hpp:118
#20 asio_handler_invoke<boost::asio::detail::binder2<boost::_bi::bind_t<void, boost::_mfi::mf2<void, smf::service::Manager, boost::system::error_code const&, int>, boost::_bi::list3<boost::_bi::value<smf::service::Manager*>, boost::arg<1>, boost::arg<2> > >, boost::system::error_code, int> > (owner=0x8123060, base=0x82567c0)
at ../../../contrib/opensource/boost/boost/asio/handler_invoke_hook.hpp:64
#21 invoke<boost::asio::detail::binder2<boost::_bi::bind_t<void, boost::_mfi::mf2<void, smf::service::Manager, boost::system::error_code const&, int>, boost::_bi::list3<boost::_bi::value<smf::service::Manager*>, boost::arg<1>, boost::arg<2> > >, boost::system::error_code, int>, boost::_bi::bind_t<void, boost::_mfi::mf2<void, smf::service::Manager, boost::system::error_code const&, int>, boost::_bi::list3<boost::_bi::value<smf::service::Manager*>, boost::arg<1>, boost::arg<2> > > > (
owner=0x8123060, base=0x82567c0) at ../../../contrib/opensource/boost/boost/asio/detail/handler_invoke_helpers.hpp:39
#22 boost::asio::detail::signal_handler<boost::_bi::bind_t<void, boost::_mfi::mf2<void, smf::service::Manager, boost::system::error_code const&, int>, boost::_bi::list3<boost::_bi::value<smf::service::Manager*>, boost::arg<1>, boost::arg<2> > > >::do_complete (owner=0x8123060, base=0x82567c0)
at ../../../contrib/opensource/boost/boost/asio/detail/signal_handler.hpp:68
#23 0x080a6243 in boost::asio::detail::task_io_service::run(boost::system::error_code&)()
#24 0x080a2b61 in run (this=0x811818c) at ../../../contrib/opensource/boost/boost/asio/impl/io_service.ipp:59
#25 smf::service::Daemon::run (this=0x811818c) at Daemon.cpp:48
#26 0x080b69a8 in boost::(anonymous namespace)::thread_proxy (param=0x8124080) at ../src/pthread/thread.cpp:143
#27 0x281346a5 in thread_start (curthread=0x8136d80) at /usr/src/lib/libthr/thread/thr_create.c:288
#28 0x00000000 in ??()
它說分段錯誤,我們需要看到最後5行導致崩潰 – Claudiordgz
AARRGGHH!我的眼睛! – 2014-03-12 21:08:43
我要走出一條肢體,並說你正在傳遞一個空的或格式不正確的日期時間,或者那個過程被破壞,並且一切都在線程中死亡。它的外觀並不是boot.thread的錯。 – Claudiordgz