From 9dfa2f4e116d424f981071159ebda9170a907f35 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Sat, 16 Feb 2013 11:11:17 -0800 Subject: [PATCH] Fixing thread segfault issues with new Boost 1.53 The answer was to use boost::move() on the functors, but since there is AFAIK no move emulation support for Boost.Function, the fix may only work on C++11 compilers. That needs to be looked into. --- cpp/BoostParts/CMakeLists.txt | 9 --------- cpp/ycm/ClangCompleter/ClangCompleter.cpp | 5 +++-- cpp/ycm/IdentifierCompleter.cpp | 4 ++-- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/cpp/BoostParts/CMakeLists.txt b/cpp/BoostParts/CMakeLists.txt index 4168225f..07b5585e 100644 --- a/cpp/BoostParts/CMakeLists.txt +++ b/cpp/BoostParts/CMakeLists.txt @@ -77,15 +77,6 @@ endif() ############################################################################# -# Due to a bug/misconfiguration/stupidity, boost 1.52 and libc++ don't like each -# other much: a compilation error "Constexpr function never produces a constant -# expression" pops up when trying to compile anything that uses -# boost/chrono/duration.hpp (namely boost/thread for us). This is a workaround -# that prevents this from happening. Also present in cpp/ycm/CMakeLists.txt. -# See here for more details: https://svn.boost.org/trac/boost/ticket/7671 -# TODO: remove this when it's fixed upstream (probably boost 1.53). -#add_definitions( -DBOOST_THREAD_DONT_USE_CHRONO ) - if( MSVC ) # BOOST_PYTHON_SOURCE makes boost use the correct __declspec and # BOOST_ALL_NO_LIB turns off MSVC library autolinking diff --git a/cpp/ycm/ClangCompleter/ClangCompleter.cpp b/cpp/ycm/ClangCompleter/ClangCompleter.cpp index a8a085fd..dcdcd1dc 100644 --- a/cpp/ycm/ClangCompleter/ClangCompleter.cpp +++ b/cpp/ycm/ClangCompleter/ClangCompleter.cpp @@ -199,7 +199,8 @@ Future< void > ClangCompleter::UpdateTranslationUnitAsync( shared_ptr< ClangPackagedTask > clang_packaged_task = make_shared< ClangPackagedTask >(); - clang_packaged_task->parsing_task_ = packaged_task< void >( functor ); + clang_packaged_task->parsing_task_ = packaged_task< void >( + boost::move( functor ) ); unique_future< void > future = clang_packaged_task->parsing_task_.get_future(); clang_task_.Set( clang_packaged_task ); @@ -341,7 +342,7 @@ void ClangCompleter::CreateClangTask( clang_packaged_task->completions_task_ = packaged_task< AsyncCompletions >( bind( ReturnValueAsShared< std::vector< CompletionData > >, - candidates_for_location_functor ) ); + boost::move( candidates_for_location_functor ) ) ); clang_task_.Set( clang_packaged_task ); } diff --git a/cpp/ycm/IdentifierCompleter.cpp b/cpp/ycm/IdentifierCompleter.cpp index ca58561a..2da0c15a 100644 --- a/cpp/ycm/IdentifierCompleter.cpp +++ b/cpp/ycm/IdentifierCompleter.cpp @@ -161,7 +161,7 @@ void IdentifierCompleter::AddCandidatesToDatabaseFromBufferAsync( boost::move( filepath ) ); buffer_identifiers_task_stack_.Push( - make_shared< packaged_task< void > >( functor ) ); + make_shared< packaged_task< void > >( boost::move( functor ) ) ); } @@ -202,7 +202,7 @@ Future< AsyncResults > IdentifierCompleter::CandidatesForQueryAndTypeAsync( QueryTask task = make_shared< packaged_task< AsyncResults > >( bind( ReturnValueAsShared< std::vector< std::string > >, - functor ) ); + boost::move( functor ) ) ); unique_future< AsyncResults > future = task->get_future();