From 3d8689d4ca9589d5e9f5e8dfef9ba43ce9253834 Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Mon, 19 Jun 2023 17:14:07 -0500 Subject: [PATCH] Making sure HPX_WITH_THREAD_BACKTRACE_ON_SUSPENSION compiles --- .circleci/config.yml | 8 ++++---- .jenkins/lsu/env-clang-14.sh | 3 +++ .../hpx/threading_base/detail/reset_backtrace.hpp | 7 ++++++- .../include/hpx/threading_base/thread_data.hpp | 2 +- .../threading_base/src/detail/reset_backtrace.cpp | 4 ++-- libs/core/threading_base/src/execution_agent.cpp | 2 +- libs/core/threading_base/src/thread_helpers.cpp | 14 ++++++++------ 7 files changed, 25 insertions(+), 15 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 26f8045e90e5..638e2a81f4d4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -224,6 +224,9 @@ jobs: /hpx/source \ -G "Ninja" \ -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_CXX_CLANG_TIDY=clang-tidy \ + -DCMAKE_CXX_FLAGS="-fcolor-diagnostics" \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=On \ -DHPX_WITH_MALLOC=system \ -DHPX_WITH_FETCH_ASIO=Off \ -DHPX_WITH_DATAPAR_BACKEND=VC \ @@ -231,13 +234,10 @@ jobs: -DHPX_WITH_GIT_BRANCH="${CIRCLE_BRANCH}" \ -DHPX_WITH_GIT_TAG="${CIRCLE_TAG}" \ -DHPX_WITH_TOOLS=On \ - -DCMAKE_CXX_FLAGS="-fcolor-diagnostics" \ -DHPX_WITH_TESTS_HEADERS=On \ -DHPX_WITH_COMPILER_WARNINGS=On \ -DHPX_WITH_COMPILER_WARNINGS_AS_ERRORS=On \ -DHPX_WITH_DEPRECATION_WARNINGS=On \ - -DCMAKE_CXX_CLANG_TIDY=clang-tidy \ - -DHPX_WITH_THREAD_LOCAL_STORAGE=On \ -DHPX_WITH_STACKTRACES_STATIC_SYMBOLS=On \ -DHPX_WITH_STACKTRACES_DEMANGLE_SYMBOLS=Off \ -DHPX_WITH_TESTS_DEBUG_LOG=On \ @@ -246,9 +246,9 @@ jobs: -DHPX_WITH_CHECK_MODULE_DEPENDENCIES=On \ -DHPX_LOGGING_WITH_SEPARATE_DESTINATIONS=Off \ -DHPX_WITH_THREAD_DEBUG_INFO=On \ + -DHPX_WITH_THREAD_LOCAL_STORAGE=On \ -DHPX_COMMAND_LINE_HANDLING_WITH_JSON_CONFIGURATION_FILES=On \ -DHPX_WITH_FETCH_JSON=On \ - -DCMAKE_EXPORT_COMPILE_COMMANDS=On \ -DHPX_WITH_DOCUMENTATION=On \ -DHPX_WITH_DOCUMENTATION_OUTPUT_FORMATS="${DOCUMENTATION_OUTPUT_FORMATS}" - persist_to_workspace: diff --git a/.jenkins/lsu/env-clang-14.sh b/.jenkins/lsu/env-clang-14.sh index a0662d0d94c3..19523eedfbb1 100644 --- a/.jenkins/lsu/env-clang-14.sh +++ b/.jenkins/lsu/env-clang-14.sh @@ -34,3 +34,6 @@ configure_extra_options+=" -DHPX_WITH_FETCH_EVE=ON" # Make sure HWLOC does not report 'cores'. This is purely an option to enable # testing the topology code under conditions close to those on FreeBSD. configure_extra_options+=" -DHPX_TOPOLOGY_WITH_ADDITIONAL_HWLOC_TESTING=ON" + +configure_extra_options+=" -DHPX_WITH_THREAD_BACKTRACE_ON_SUSPENSION=ON" +configure_extra_options+=" -DHPX_WITH_THREAD_FULLBACKTRACE_ON_SUSPENSION=ON" diff --git a/libs/core/threading_base/include/hpx/threading_base/detail/reset_backtrace.hpp b/libs/core/threading_base/include/hpx/threading_base/detail/reset_backtrace.hpp index 71f81e5ab504..d44a5ef617cf 100644 --- a/libs/core/threading_base/include/hpx/threading_base/detail/reset_backtrace.hpp +++ b/libs/core/threading_base/include/hpx/threading_base/detail/reset_backtrace.hpp @@ -10,12 +10,15 @@ #ifdef HPX_HAVE_THREAD_BACKTRACE_ON_SUSPENSION -#include #include #include #include +#ifdef HPX_HAVE_THREAD_FULLBACKTRACE_ON_SUSPENSION #include +#endif + +#include namespace hpx::threads::detail { @@ -40,4 +43,6 @@ namespace hpx::threads::detail { }; } // namespace hpx::threads::detail +#include + #endif // HPX_HAVE_THREAD_BACKTRACE_ON_SUSPENSION diff --git a/libs/core/threading_base/include/hpx/threading_base/thread_data.hpp b/libs/core/threading_base/include/hpx/threading_base/thread_data.hpp index 0da75d2b1a8c..76a972f18c33 100644 --- a/libs/core/threading_base/include/hpx/threading_base/thread_data.hpp +++ b/libs/core/threading_base/include/hpx/threading_base/thread_data.hpp @@ -421,7 +421,7 @@ namespace hpx::threads { spinlock_pool::spinlock_for(this)); std::string bt; - if (0 != backtrace_) + if (nullptr != backtrace_) { #ifdef HPX_HAVE_THREAD_FULLBACKTRACE_ON_SUSPENSION bt = *backtrace_; diff --git a/libs/core/threading_base/src/detail/reset_backtrace.cpp b/libs/core/threading_base/src/detail/reset_backtrace.cpp index 1bc03540dfc9..54f28ee8b9b4 100644 --- a/libs/core/threading_base/src/detail/reset_backtrace.cpp +++ b/libs/core/threading_base/src/detail/reset_backtrace.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2022 Hartmut Kaiser +// Copyright (c) 2020-2023 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -36,7 +36,7 @@ namespace hpx::threads::detail { reset_backtrace::~reset_backtrace() { - threads::set_thread_backtrace(id_, 0, ec_); + threads::set_thread_backtrace(id_, nullptr, ec_); } } // namespace hpx::threads::detail diff --git a/libs/core/threading_base/src/execution_agent.cpp b/libs/core/threading_base/src/execution_agent.cpp index 5a0d21171040..2205f8f6ba12 100644 --- a/libs/core/threading_base/src/execution_agent.cpp +++ b/libs/core/threading_base/src/execution_agent.cpp @@ -184,7 +184,7 @@ namespace hpx::threads { id.noref(), threads::thread_description(desc)); #endif #ifdef HPX_HAVE_THREAD_BACKTRACE_ON_SUSPENSION - threads::detail::reset_backtrace bt(id); + threads::detail::reset_backtrace bt(id.noref()); #endif [[maybe_unused]] on_exit_reset_held_lock_data held_locks; diff --git a/libs/core/threading_base/src/thread_helpers.cpp b/libs/core/threading_base/src/thread_helpers.cpp index cac1b91c17e8..a5e118494cef 100644 --- a/libs/core/threading_base/src/thread_helpers.cpp +++ b/libs/core/threading_base/src/thread_helpers.cpp @@ -294,7 +294,9 @@ namespace hpx::threads { #endif //////////////////////////////////////////////////////////////////////////// - static thread_local std::size_t continuation_recursion_count(0); + namespace { + thread_local std::size_t continuation_recursion_count(0); + } std::size_t& get_continuation_recursion_count() noexcept { @@ -438,7 +440,7 @@ namespace hpx::this_thread { threads::thread_self& self = threads::get_self(); // keep alive - threads::thread_id_ref_type id = self.get_thread_id(); + threads::thread_id_ref_type const id = self.get_thread_id(); // handle interruption, if needed threads::interruption_point(id.noref(), ec); @@ -448,8 +450,8 @@ namespace hpx::this_thread { threads::thread_restart_state statex; { - // verify that there are no more registered locks for this OS-thread #ifdef HPX_HAVE_VERIFY_LOCKS + // verify that there are no more registered locks for this OS-thread util::verify_no_locks(); #endif #ifdef HPX_HAVE_THREAD_DESCRIPTION @@ -457,7 +459,7 @@ namespace hpx::this_thread { id.noref(), description, ec); #endif #ifdef HPX_HAVE_THREAD_BACKTRACE_ON_SUSPENSION - threads::detail::reset_backtrace bt(id, ec); + threads::detail::reset_backtrace bt(id.noref(), ec); #endif // We might need to dispatch 'nextid' to it's correct scheduler only // if our current scheduler is the same, we should yield to the id @@ -509,7 +511,7 @@ namespace hpx::this_thread { threads::thread_self& self = threads::get_self(); // keep alive - threads::thread_id_ref_type id = self.get_thread_id(); + threads::thread_id_ref_type const id = self.get_thread_id(); // handle interruption, if needed threads::interruption_point(id.noref(), ec); @@ -529,7 +531,7 @@ namespace hpx::this_thread { id.noref(), description, ec); #endif #ifdef HPX_HAVE_THREAD_BACKTRACE_ON_SUSPENSION - threads::detail::reset_backtrace bt(id, ec); + threads::detail::reset_backtrace bt(id.noref(), ec); #endif std::atomic timer_started(false); threads::thread_id_ref_type const timer_id =