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 all commits
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
40 changes: 40 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,36 @@
#include <thread>
#include <utility>

#if defined(HPX_HAVE_LOGGING)
namespace hpx { namespace detail {
void try_log_runtime_threads()
{
// This may be used in non-valid runtime states, let it fail silently
try
{
auto rt = hpx::get_runtime_ptr();
if (rt == nullptr)
return;

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;
});
}
catch (...)
{
}
}
}}; // namespace hpx::detail
Pansysk75 marked this conversation as resolved.
Show resolved Hide resolved
#endif

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

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

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

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

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