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

이 커밋은 다음에 포함됨:
habajpai-amd 작성하고 GitHub가 2025-12-19 11:56:40 +05:30를 커밋함
1 부모 883fdfb820
커밋 7b00d3a89b
3 파일이 변경됨
+50 -7

검색과 일치하는 파일 없음

+14 -2
파일 보기
@@ -31,8 +31,6 @@
} \
} // namespace ::tim::cereal
#include "common/defines.h"
#if !defined(ROCPROFSYS_USE_ROCM)
# define ROCPROFSYS_USE_ROCM 0
#endif
@@ -43,6 +41,7 @@
#include <timemory/manager.hpp>
#include <dlfcn.h>
#include <string>
#include "core/agent_manager.hpp"
@@ -90,6 +89,17 @@ _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()
{
@@ -100,6 +110,8 @@ 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)
{
ROCPROFSYS_BASIC_VERBOSE(1, "Exception thrown initializing amd-smi: %s\n",