Skip to content

Fix SWDEV-473314 by avoiding empty unique_ptr dereference #371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 27, 2024

Conversation

jamesxu2
Copy link
Contributor

  • Revert part of blamed commit modifying source/lib/omnitrace/library/components/roctracer.cpp with goal of "clear roctracer_data storage if roctracer not initialized"
  • Particularly, I don't think tim::storage<comp::roctracer_data>::instance() returns the instance of the storage singleton if it exists, but rather creates an empty unique_ptr to the storage type

- Revert part of b134a68
	modifying source/lib/omnitrace/library/components/roctracer.cpp
@jamesxu2 jamesxu2 requested a review from dgaliffiAMD August 14, 2024 20:36
@jamesxu2 jamesxu2 requested a review from jrmadsen as a code owner August 14, 2024 20:36
@jamesxu2
Copy link
Contributor Author

I can clarify my statement about "tim::storagecomp::roctracer_data::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());
}

@dgaliffiAMD dgaliffiAMD merged commit 395c330 into main Aug 27, 2024
5 of 43 checks passed
@dgaliffiAMD dgaliffiAMD deleted the SWDEV-473314 branch August 27, 2024 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants