id summary reporter owner description type status milestone component version severity resolution keywords cc 11275 Deadlock when destroying continuation future Konrad Zemek viboes "I've stumbled upon a deadlock somewhere in continuation logic. I think the trace below will show it clearly. Basically, the future's destructor waits on lock that was already locked earlier in the callstack: In the continuation sequence: {{{ #22 0x0000000000505283 in boost::detail::shared_state_base::do_continuation (this=0x18979d0, lock=...) at /usr/include/boost/thread/future.hpp:239 239 } (gdb) print lock $2 = (boost::unique_lock &) @0x7f6e62783520: {m = 0x1897a10, is_locked = true} }}} Later during destruction: {{{ #7 0x0000000000505083 in boost::detail::shared_state_base::dec (this=0x18979d0) at /usr/include/boost/thread/future.hpp:197 197 void dec() { boost::unique_lock lk(this->mutex); dec(lk); } (gdb) print lk $4 = {m = 0x1897a10, is_locked = false} }}} Following is the trace from GDB. I attach my version of future.hpp for line number reference. It's the version from 71d9a0a merged with boost-1.58 tag. {{{ Thread 2 (Thread 0x7f6e62786700 (LWP 12760)): #0 __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135 #1 0x00007f6e64b8156a in _L_lock_913 () from /lib/x86_64-linux-gnu/libpthread.so.0 #2 0x00007f6e64b81390 in __GI___pthread_mutex_lock (mutex=0x1897a10) at ../nptl/pthread_mutex_lock.c:79 #3 0x000000000050236a in pthread_mutex_lock (m=0x1897a10) at /usr/include/boost/thread/pthread/mutex.hpp:62 #4 boost::mutex::lock (this=0x1897a10) at /usr/include/boost/thread/pthread/mutex.hpp:116 #5 0x000000000050f881 in boost::unique_lock::lock (this=0x7f6e627831f0) at /usr/include/boost/thread/lock_types.hpp:346 #6 0x000000000050f9e9 in boost::unique_lock::unique_lock (this=0x7f6e627831f0, m_=...) at /usr/include/boost/thread/lock_types.hpp:124 #7 0x0000000000505083 in boost::detail::shared_state_base::dec (this=0x18979d0) at /usr/include/boost/thread/future.hpp:197 #8 0x000000000052850e in boost::detail::basic_future > > >::~basic_future (this=0x1897c58, __in_chrg=) at /usr/include/boost/thread/future.hpp:1212 #9 0x000000000051f46e in boost::future > > >::~future (this=0x1897c58, __in_chrg=) at /usr/include/boost/thread/future.hpp:1822 #10 0x0000000000534fbc in boost::detail::future_unwrap_shared_state > > >, std::unique_ptr > >::~future_unwrap_shared_state (this=0x1897b40, __in_chrg=) at /usr/include/boost/thread/future.hpp:5043 #11 0x0000000000534ff8 in boost::detail::future_unwrap_shared_state > > >, std::unique_ptr > >::~future_unwrap_shared_state (this=0x1897b40, __in_chrg=) at /usr/include/boost/thread/future.hpp:5043 #12 0x0000000000535030 in boost::checked_delete > > >, std::unique_ptr > > > (x=0x1897b40) at /usr/include/boost/core/checked_delete.hpp:34 #13 0x00000000005382ee in boost::detail::sp_counted_impl_p > > >, std::unique_ptr > > >::dispose (this=0x1897880) at /usr/include/boost/smart_ptr/detail/sp_counted_impl.hpp:78 #14 0x00000000005017e2 in boost::detail::sp_counted_base::release (this=0x1897880) at /usr/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:146 #15 0x00000000005018a5 in boost::detail::shared_count::~shared_count (this=0x7f6e5c0008c8, __in_chrg=) at /usr/include/boost/smart_ptr/detail/shared_count.hpp:443 #16 0x0000000000505114 in boost::shared_ptr::~shared_ptr (this=0x7f6e5c0008c0, __in_chrg=) at /usr/include/boost/smart_ptr/shared_ptr.hpp:323 #17 0x000000000052f13e in std::_Destroy > (__pointer=0x7f6e5c0008c0) at /usr/include/c++/4.9/bits/stl_construct.h:93 #18 0x0000000000529d5d in std::_Destroy_aux::__destroy*> ( __first=0x7f6e5c0008c0, __last=0x7f6e5c0008d0) at /usr/include/c++/4.9/bits/stl_construct.h:103 #19 0x00000000005228f3 in std::_Destroy*> (__first=0x7f6e5c0008c0, __last=0x7f6e5c0008d0) at /usr/include/c++/4.9/bits/stl_construct.h:126 #20 0x0000000000516107 in std::_Destroy*, boost::shared_ptr > (__first=0x7f6e5c0008c0, __last=0x7f6e5c0008d0) at /usr/include/c++/4.9/bits/stl_construct.h:151 #21 0x000000000050d24f in std::vector, std::allocator > >::~vector (this=0x7f6e62783450, __in_chrg=) at /usr/include/c++/4.9/bits/stl_vector.h:424 #22 0x0000000000505283 in boost::detail::shared_state_base::do_continuation (this=0x18979d0, lock=...) at /usr/include/boost/thread/future.hpp:239 #23 0x0000000000505412 in boost::detail::shared_state_base::mark_finished_internal (this=0x18979d0, lock=...) at /usr/include/boost/thread/future.hpp:265 #24 0x0000000000544a2d in boost::detail::shared_state > > >::mark_finished_with_result_internal(boost::future > >&&, boost::unique_lock&) (this=0x18979d0, result_=, lock=...) at /usr/include/boost/thread/future.hpp:526 #25 0x000000000054499f in boost::detail::shared_state > > >::mark_finished_with_result(boost::future > >&&) (this=0x18979d0, ---Type to continue, or q to quit--- result_=) at /usr/include/boost/thread/future.hpp:554 #26 0x00000000005448be in _ZN5boost6detail41future_executor_continuation_shared_stateINS_9executors17basic_thread_poolENS_6futureIvEENS4_ISt10unique_ptrIN3one7clproto13ServerMessageESt14default_deleteIS9_EEEEZNS7_13communication6layers5InboxI10LowerLayerE11communicateES6_INS8_13ClientMessageESA_ISJ_EEiEUlT_E_E3runENS_10shared_ptrINS0_17shared_state_baseEEE (that_=...) at /usr/include/boost/thread/future.hpp:4303 #27 0x0000000000544738 in _ZN5boost6detail6run_itINS0_41future_executor_continuation_shared_stateINS_9executors17basic_thread_poolENS_6futureIvEENS5_ISt10unique_ptrIN3one7clproto13ServerMessageESt14default_deleteISA_EEEEZNS8_13communication6layers5InboxI10LowerLayerE11communicateES7_INS9_13ClientMessageESB_ISK_EEiEUlT_E_EEEclEv (this=0x18978a8) at /usr/include/boost/thread/future.hpp:4274 #28 0x00000000005445ba in _ZN5boost6detail16nullary_functionIFvvEE9impl_typeINS0_6run_itINS0_41future_executor_continuation_shared_stateINS_9executors17basic_thread_poolENS_6futureIvEENS9_ISt10unique_ptrIN3one7clproto13ServerMessageESt14default_deleteISE_EEEEZNSC_13communication6layers5InboxI10LowerLayerE11communicateESB_INSD_13ClientMessageESF_ISO_EEiEUlT_E_EEEEE4callEv ( this=0x18978a0) at /usr/include/boost/thread/detail/nullary_function.hpp:52 #29 0x0000000000507245 in boost::detail::nullary_function::operator()() (this=0x7f6e62783690) at /usr/include/boost/thread/detail/nullary_function.hpp:125 #30 0x00000000005072a3 in boost::executors::basic_thread_pool::worker_thread (this=0x1894ba0) at /usr/include/boost/thread/executors/basic_thread_pool.hpp:91 #31 0x000000000053f129 in boost::detail::invoke*>(void (boost::executors::basic_thread_pool::*&&)(), boost::executors::basic_thread_pool<>*&&, (boost::executors::basic_thread_pool<>*&&)...) ( f=, a0=) at /usr/include/boost/thread/detail/invoke.hpp:77 #32 0x000000000053c705 in boost::detail::thread_data::run2<1ul> (this=0x1894f20) at /usr/include/boost/thread/detail/thread.hpp:75 #33 0x0000000000538e5a in boost::detail::thread_data::run (this=0x1894f20) at /usr/include/boost/thread/detail/thread.hpp:81 #34 0x00007f6e64da5d8a in ?? () from /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.58.0 #35 0x00007f6e64b7f0a5 in start_thread (arg=0x7f6e62786700) at pthread_create.c:309 #36 0x00007f6e63e1ecfd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111 }}}" Support Requests closed thread Boost 1.58.0 Problem worksforme continuation deadlock destructor