Skip to content

Memory leak in Tf_RegistryImpl #3088

@dtoshevcg

Description

@dtoshevcg

Description of Issue

We are seeing a strange memory leak report when running a binary compiled with Clang's address sanitizer linked with USD v23.11. That is, our code is compiled with address sanitizer enabled, while USD is compiled in release mode using its own script and gcc 11. The error from ASAN is:

==1591245==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1544 byte(s) in 1 object(s) allocated from:
    #0 0x39ff87 in operator new(unsigned long)
    #1 0x7f54cf89fcd6 in std::vector<__gnu_cxx::_Hashtable_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::list<pxrInternal_v0_23__pxrReserved__::(anonymous namespace)::Tf_RegistryManagerImpl::_RegistrationValue, std::allocator<pxrInternal_v0_23__pxrReserved__::(anonymous namespace)::Tf_RegistryManagerImpl::_RegistrationValue> > > >*, std::allocator<__gnu_cxx::_Hashtable_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::list<pxrInternal_v0_23__pxrReserved__::(anonymous namespace)::Tf_RegistryManagerImpl::_RegistrationValue, std::allocator<pxrInternal_v0_23__pxrReserved__::(anonymous namespace)::Tf_RegistryManagerImpl::_RegistrationValue> > > >*> >::reserve(unsigned long) (.constprop.0) registryManager.cpp

From that I gather that the Tf_RegistryManagerImpl's _registrationFunctions member is not freed, which is strange, because the singleton instance itself is freed. The leak is always reproducible and doesn't require calling any USD functions beyond the DSO's initialisation.

Steps to Reproduce

  1. Run any binary compiled with Clang and address sanitizer, linked with USD v23.11 on Rocky 8.

System Information (OS, Hardware)

Rocky Linux 8

Package Versions

USD: v23.11
Compiler used for USD: gcc (GCC) 11.2.1 20220127 (Red Hat 11.2.1-9)
Compiler used for our code: clang version 14.0.6

Build Flags

build_usd.py --build-variant=release --materialx --no-prman --no-tutorials --no-examples --no-docs --no-tools --no-python --use-cxx11-abi=1

Edit: fixed formatting

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions