Skip to content

Commit

Permalink
Update bin/omnitrace-avail/avail.cpp
Browse files Browse the repository at this point in the history
- statically allocate shared pointers for timemory manager and hash id/aliases to prevent use-after-free errors
  • Loading branch information
jrmadsen committed Apr 23, 2024
1 parent 22a2ca0 commit 679455b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions source/bin/omnitrace-avail/avail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#include <timemory/components/placeholder.hpp>
#include <timemory/components/properties.hpp>
#include <timemory/components/skeletons.hpp>
#include <timemory/hash/types.hpp>
#include <timemory/manager/manager.hpp>
#include <timemory/mpl/types.hpp>
#include <timemory/timemory.hpp>
#include <timemory/unwind/bfd.hpp>
Expand Down Expand Up @@ -118,13 +120,22 @@ 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

//--------------------------------------------------------------------------------------//

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();
Expand Down

0 comments on commit 679455b

Please sign in to comment.