From 1757d04c51514b20db8dabc18788a3fa8df8325e Mon Sep 17 00:00:00 2001 From: "Jonathan R. Madsen" Date: Thu, 22 Feb 2024 11:51:05 -0600 Subject: [PATCH] Update bin/omnitrace-avail/avail.cpp - statically allocate shared pointers for timemory manager and hash id/aliases to prevent use-after-free errors --- source/bin/omnitrace-avail/avail.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/bin/omnitrace-avail/avail.cpp b/source/bin/omnitrace-avail/avail.cpp index e4e474b1f..53031f2f4 100644 --- a/source/bin/omnitrace-avail/avail.cpp +++ b/source/bin/omnitrace-avail/avail.cpp @@ -41,6 +41,8 @@ #include #include #include +#include +#include #include #include #include @@ -118,6 +120,11 @@ namespace { // initialize HIP before main so that libomnitrace is not HSA_TOOLS_LIB int gpu_count = omnitrace::gpu::hip_device_count(); + +// statically allocated shared_ptrs to prevent use after free errors +auto timemory_manager = tim::manager::master_instance(); +auto timemory_hash_ids = tim::hash::get_main_hash_ids(); +auto timemory_hash_aliases = tim::hash::get_main_hash_aliases(); } // namespace //--------------------------------------------------------------------------------------// @@ -125,6 +132,10 @@ int gpu_count = omnitrace::gpu::hip_device_count(); int main(int argc, char** argv) { + (void) timemory_manager; // suppress unused variables + (void) timemory_hash_ids; // + (void) timemory_hash_aliases; // + tim::unwind::set_bfd_verbose(3); tim::set_env("OMNITRACE_INIT_TOOLING", "OFF", 1); omnitrace_init_library();