Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log alive hpx threads on exit #6340

Merged
merged 2 commits into from
Sep 10, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions libs/core/runtime_local/src/runtime_local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,27 @@
#include <thread>
#include <utility>

namespace hpx{ namespace detail {
void log_all_runtime_threads()
{
auto rt = hpx::get_runtime_ptr();
if (rt)
{
rt->get_thread_manager().enumerate_threads(
[](hpx::threads::thread_id_type id) -> bool {
hpx::threads::thread_data* td = get_thread_id_data(id);
auto sched = td->get_scheduler_base();
LTM_(debug).format(
"Logging all runtime threads: pool({}), scheduler({}),"
"thread({}), description({}), state({})",
sched->get_parent_pool(), sched, id,
td->get_description(), td->get_state().state());
return true;
});
}
}
}}; // namespace hpx::detail
Pansysk75 marked this conversation as resolved.
Show resolved Hide resolved

///////////////////////////////////////////////////////////////////////////////
// Make sure the system gets properly shut down while handling Ctrl-C and other
// system signals
Expand Down Expand Up @@ -91,6 +112,11 @@ namespace hpx {
}
#endif

#if defined(HPX_HAVE_LOGGING)
LRT_(debug).format("Terminating due to system signal({})", reason);
hpx::detail::log_all_runtime_threads();
#endif

std::cerr << "{what}: " << (reason ? reason : "Unknown reason")
<< "\n";
}
Expand Down Expand Up @@ -164,6 +190,11 @@ namespace hpx {
}
#endif

#if defined(HPX_HAVE_LOGGING)
LRT_(debug).format("Terminating due to system signal({})", signum);
hpx::detail::log_all_runtime_threads();
#endif

std::cerr << "{what}: " << (reason ? reason : "Unknown reason")
<< "\n";
}
Expand Down