Revert "fix: prevent double-free crash during process exit in amd-smi (#2213)" (#2640)

This reverts commit 7b00d3a89b.

The workaround is no longer needed - root cause fixed in:
- rocm-smi-lib (PR #2531): Made devInfoTypesStrings file-local static
- amdsmi (PR #2575): Added visibility("hidden") attribute
This commit is contained in:
habajpai-amd
2026-01-17 02:38:52 +05:30
committato da GitHub
parent 005f07004d
commit b53c99669c
3 ha cambiato i file con 7 aggiunte e 37 eliminazioni
@@ -31,6 +31,8 @@
} \
} // namespace ::tim::cereal
#include "common/defines.h"
#if !defined(ROCPROFSYS_USE_ROCM)
# define ROCPROFSYS_USE_ROCM 0
#endif
@@ -40,7 +42,6 @@
#include <timemory/manager.hpp>
#include <dlfcn.h>
#include <string>
#include "core/agent_manager.hpp"
@@ -92,17 +93,6 @@ _amdsmi_is_initialized()
return initialized;
}
void
prevent_amdsmi_library_unload()
{
static bool _initialized = false;
if(_initialized) return;
_initialized = true;
dlopen("libamd_smi.so", RTLD_NOW | RTLD_NOLOAD | RTLD_NODELETE);
dlopen("librocm_smi64.so", RTLD_NOW | RTLD_NOLOAD | RTLD_NODELETE);
}
bool
amdsmi_init()
{
@@ -113,8 +103,6 @@ amdsmi_init()
ROCPROFSYS_AMD_SMI_CALL(::amdsmi_init(AMDSMI_INIT_AMD_GPUS));
get_processor_handles();
_amdsmi_is_initialized() = true; // Mark as initialized
prevent_amdsmi_library_unload();
} catch(std::exception& _e)
{
LOG_ERROR("Exception thrown initializing amd-smi: {}", _e.what());
@@ -1272,7 +1272,10 @@ shutdown()
try
{
data::shutdown();
if(data::shutdown())
{
ROCPROFSYS_AMD_SMI_CALL(amdsmi_shut_down());
}
} catch(std::runtime_error& _e)
{
LOG_WARNING("Exception thrown when shutting down amd-smi: {}", _e.what());
@@ -24,6 +24,7 @@
#include "core/common.hpp"
#include "core/config.hpp"
#include "core/state.hpp"
#include "core/timemory.hpp"
#include "library/runtime.hpp"
#include <timemory/backends/threading.hpp>
@@ -33,9 +34,7 @@
#include "logger/debug.hpp"
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <unistd.h>
namespace rocprofsys
{
@@ -89,26 +88,6 @@ void
exit_gotcha::operator()(const gotcha_data& _data, exit_func_t _func, int _ec) const
{
_exit_info = { true, _data.tool_id.find("quick") != std::string::npos, _ec };
if(config::get_use_amd_smi())
{
threading::clear_callbacks();
if(get_state() < ::rocprofsys::State::Finalized && !is_child_process())
{
LOG_DEBUG("Finalizing {} before calling {}({})...", get_exe_name(),
_data.tool_id, _ec);
rocprofsys_finalize();
}
LOG_DEBUG("Calling _exit({}) in {} to avoid AMD SMI cleanup issues...", _ec,
get_exe_name().c_str());
std::fflush(nullptr);
_exit(_ec);
}
invoke_exit_gotcha(_data, _func, _ec);
}