diff --git a/runtime/hsa-runtime/loader/executable.cpp b/runtime/hsa-runtime/loader/executable.cpp index 5d65a32b97..2713e9a07e 100644 --- a/runtime/hsa-runtime/loader/executable.cpp +++ b/runtime/hsa-runtime/loader/executable.cpp @@ -188,6 +188,10 @@ static void RemoveCodeObjectInfoFromDebugMap(link_map* map) { if (r_debug_tail == map) { r_debug_tail = map->l_prev; } + if (_amdgpu_r_debug.r_map == map) { + _amdgpu_r_debug.r_map = map->l_next; + } + if (map->l_prev) { map->l_prev->l_next = map->l_next; } @@ -196,6 +200,7 @@ static void RemoveCodeObjectInfoFromDebugMap(link_map* map) { } delete map->l_name; + memset(map, 0, sizeof(link_map)); } hsa_status_t AmdHsaCodeLoader::FreezeExecutable(Executable *executable, const char *options) { diff --git a/runtime/hsa-runtime/loader/executable.hpp b/runtime/hsa-runtime/loader/executable.hpp index 368b9aefc5..dc674509fc 100644 --- a/runtime/hsa-runtime/loader/executable.hpp +++ b/runtime/hsa-runtime/loader/executable.hpp @@ -54,6 +54,7 @@ #include #include #include +#include #include "hsa.h" #include "hsa_ext_image.h" #include "amd_hsa_loader.hpp" @@ -295,7 +296,9 @@ private: public: LoadedCodeObjectImpl(ExecutableImpl *owner_, hsa_agent_t agent_, const void *elf_data_, size_t elf_size_) - : ExecutableObject(owner_, agent_), elf_data(elf_data_), elf_size(elf_size_) {} + : ExecutableObject(owner_, agent_), elf_data(elf_data_), elf_size(elf_size_) { + memset(&r_debug_info, 0, sizeof(r_debug_info)); + } const void* ElfData() const { return elf_data; } size_t ElfSize() const { return elf_size; }