ROCm / omnitrace

Omnitrace: Application Profiling, Tracing, and Analysis
https://rocm.docs.amd.com/projects/omnitrace/en/latest/
MIT License
297 stars 27 forks source link

Fix SWDEV-473314 by avoiding empty unique_ptr dereference #371

Closed jamesxu2 closed 1 month ago

jamesxu2 commented 2 months ago
jamesxu2 commented 1 month ago

I can clarify my statement about "tim::storage::instance()": This instance() function uses specialized templates and calls into the wrong (generic) version yielding a false positive signal that "there is still roctracer_data that needs to be destroyed in the storage singleton".

File src: source\lib\omnitrace\library\thread_data.hpp


// Generic Template, which is being called and returns a pointer to uninitialized structure
template <typename Tp, typename Tag, size_t MaxThreads>
unique_ptr_t<thread_data<std::optional<Tp>, Tag, MaxThreads>>&
thread_data<std::optional<Tp>, Tag, MaxThreads>::instance()
{
    static auto _v = unique_ptr_t<this_type>{};
    return _v;
}

// Specialized Template, which you want to call but is not used. Returns a pointer to the singleton
template <typename Tp, typename Tag, size_t MaxThreads>
unique_ptr_t<Tp>&
thread_data<Tp, Tag, MaxThreads>::instance()
{
    return instances().at(threading::get_id());
}