From f727b3358d3473ff7e2e03300183620d301b9d96 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 | 6 ++++++ .../include/hpx/threading_base/thread_data.hpp | 2 +- .../core/threading_base/src/detail/reset_backtrace.cpp | 4 ++-- libs/core/threading_base/src/execution_agent.cpp | 3 ++- libs/core/threading_base/src/thread_helpers.cpp | 10 +++++----- 7 files changed, 23 insertions(+), 13 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 312201627ae5..344f78aa320a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -225,6 +225,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 \ @@ -232,13 +235,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 \ @@ -247,9 +247,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}" \ -DHPX_WITH_TESTS_COMMAND_LINE=--hpx:queuing=local-workrequesting-fifo diff --git a/.jenkins/lsu/env-clang-14.sh b/.jenkins/lsu/env-clang-14.sh index 144c17e7820d..9f7d21480ae8 100644 --- a/.jenkins/lsu/env-clang-14.sh +++ b/.jenkins/lsu/env-clang-14.sh @@ -37,3 +37,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 468c656def8a..d68bc91a8449 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 @@ -15,7 +15,11 @@ #include #include +#ifdef HPX_HAVE_THREAD_FULLBACKTRACE_ON_SUSPENSION #include +#endif + +#include namespace hpx::threads::detail { @@ -40,4 +44,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 ff4e8348cb25..c00579655866 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 @@ -422,7 +422,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 ae47ba48634f..43840038828a 100644 --- a/libs/core/threading_base/src/execution_agent.cpp +++ b/libs/core/threading_base/src/execution_agent.cpp @@ -167,7 +167,8 @@ namespace hpx::threads { id.noref(), threads::thread_description(desc)); #endif #if defined(HPX_HAVE_THREAD_BACKTRACE_ON_SUSPENSION) - [[maybe_unused]] threads::detail::reset_backtrace reset_bt(id); + [[maybe_unused]] threads::detail::reset_backtrace reset_bt( + id.noref()); #endif #if defined(HPX_HAVE_VERIFY_LOCKS) [[maybe_unused]] auto held_locks = hpx::experimental::scope_exit( diff --git a/libs/core/threading_base/src/thread_helpers.cpp b/libs/core/threading_base/src/thread_helpers.cpp index 810bf734686e..981df930f26b 100644 --- a/libs/core/threading_base/src/thread_helpers.cpp +++ b/libs/core/threading_base/src/thread_helpers.cpp @@ -441,7 +441,7 @@ namespace hpx::this_thread { threads::thread_self& self = threads::get_self(); // keep alive - threads::thread_id_ref_type id = self.get_outer_thread_id(); + threads::thread_id_ref_type const id = self.get_outer_thread_id(); // handle interruption, if needed threads::interruption_point(id.noref(), ec); @@ -451,8 +451,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 @@ -460,7 +460,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 @@ -512,7 +512,7 @@ namespace hpx::this_thread { threads::thread_self& self = threads::get_self(); // keep alive - threads::thread_id_ref_type id = self.get_outer_thread_id(); + threads::thread_id_ref_type const id = self.get_outer_thread_id(); // handle interruption, if needed threads::interruption_point(id.noref(), ec); @@ -532,7 +532,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 =