Skip to content
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

[DllLibCurl][TestXBMCTinyXML2] Fix memory leaks #24211

Merged
merged 2 commits into from
Dec 11, 2023
Merged

Conversation

neo1973
Copy link
Member

@neo1973 neo1973 commented Dec 10, 2023

Description

Fixes two memory leaks observed when running the unit tests. Details are in the commit messages.

Motivation and context

Fewer errors when running unit tests with address sanitizer.

How has this been tested?

Address sanitizer is happy, no problems when runtime testing Kodi.

What is the effect on users?

None.

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • Clean up (non-breaking change which removes non-working, unmaintained functionality)
  • Improvement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that will cause existing functionality to change)
  • Cosmetic change (non-breaking change that doesn't touch code)
  • Student submission (PR was done for educational purposes and will be treated as such)
  • None of the above (please explain below)

Checklist:

  • My code follows the Code Guidelines of this project
  • My change requires a change to the documentation, either Doxygen or wiki
  • I have updated the documentation accordingly
  • I have read the Contributing document
  • I have added tests to cover my change
  • All new and existing tests passed

Address Sanitizer output:

Direct leak of 576 byte(s) in 1 object(s) allocated from:
    #0 0x556652b7d482 in operator new(unsigned long) (kodi-test+0xa2f0482) (BuildId: eac9932a781e7c589c3657d6336c0cb0767a5cee)
    xbmc#1 0x5566531a951d in CXBMCTestUtils::CreateTempFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) xbmc/test/TestUtils.cpp:99:18
    xbmc#2 0x556652c39f08 in TestXBMCTinyXML2_SaveFile_Test::TestBody() xbmc/utils/test/TestXBMCTinyXML2.cpp:123:10
    xbmc#3 0x7fad8d11665b  (/usr/lib/libgtest.so.1.14.0+0x5365b) (BuildId: d3f0da00423297c687edfdde9cb59f357b95e001)

Indirect leak of 43 byte(s) in 1 object(s) allocated from:
    #0 0x556652b7d482 in operator new(unsigned long) (/home/mark/Coding/Repos/kodi-git/build_clang_debug_sanitizer/kodi-test+0xa2f0482) (BuildId: eac9932a781e7c589c3657d6336c0cb0767a5cee)
    xbmc#1 0x556652b90196 in std::__new_allocator<char>::allocate(unsigned long, void const*) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/new_allocator.h:147:27
    xbmc#2 0x556652b9001c in std::allocator_traits<std::allocator<char>>::allocate(std::allocator<char>&, unsigned long) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/alloc_traits.h:482:20
    xbmc#3 0x556652b9001c in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::_S_allocate(std::allocator<char>&, unsigned long) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/basic_string.h:126:16
    xbmc#4 0x556652b8fd5f in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::_M_create(unsigned long&, unsigned long) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/basic_string.tcc:155:14
    xbmc#5 0x556652b946a3 in void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/basic_string.tcc:225:14
    xbmc#6 0x556652b869e1 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::basic_string<std::allocator<char>>(char const*, std::allocator<char> const&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/basic_string.h:639:2
    xbmc#7 0x55665429a52b in KODI::PLATFORM::FILESYSTEM::temp_file_path(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::error_code&) xbmc/platform/posix/Filesystem.cpp:122:10
    xbmc#8 0x5566531adeac in CTempFile::Create(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) xbmc/test/TestUtils.cpp:40:23
    xbmc#9 0x5566531a95eb in CXBMCTestUtils::CreateTempFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) xbmc/test/TestUtils.cpp:100:10
    xbmc#10 0x556652c39f08 in TestXBMCTinyXML2_SaveFile_Test::TestBody() xbmc/utils/test/TestXBMCTinyXML2.cpp:123:10
    xbmc#11 0x7fad8d11665b  (/usr/lib/libgtest.so.1.14.0+0x5365b) (BuildId: d3f0da00423297c687edfdde9cb59f357b95e001)
Fixes memory leaks like this:

Direct leak of 5416 byte(s) in 1 object(s) allocated from:
    #0 0x564b473d8ba1 in calloc (kodi-test+0xa2a8ba1) (BuildId: e17174d164cea5687c750d197e31e6bf0beb86ad)
    xbmc#1 0x7f6be8db88fa  (/usr/lib/libcurl.so.4+0x708fa) (BuildId: b5fe52836b4db517485d04822e61ce49b2793833)
    xbmc#2 0x564b4fb89895 in XCURL::DllLibCurlGlobal::easy_acquire(char const*, char const*, void**, void**) xbmc/filesystem/DllLibCurl.cpp:208:22
    xbmc#3 0x564b4facc484 in XFILE::CCurlFile::Open(CURL const&) xbmc/filesystem/CurlFile.cpp:1086:21
    xbmc#4 0x564b4fac72a0 in XFILE::CCurlFile::Service(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&) xbmc/filesystem/CurlFile.cpp:966:7
    xbmc#5 0x564b4fac7a69 in XFILE::CCurlFile::Get(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&) xbmc/filesystem/CurlFile.cpp:960:10
    xbmc#6 0x564b47bbd6f6 in TestWebServer_CanGetCachedRangedFileWithExactIfRange_Test::TestBody() xbmc/network/test/TestWebServer.cpp:900:3
    xbmc#7 0x7f6be969665b  (/usr/lib/libgtest.so.1.14.0+0x5365b) (BuildId: d3f0da00423297c687edfdde9cb59f357b95e001)

Indirect leak of 5416 byte(s) in 1 object(s) allocated from:
    #0 0x564b473d8ba1 in calloc (kodi-test+0xa2a8ba1) (BuildId: e17174d164cea5687c750d197e31e6bf0beb86ad)
    xbmc#1 0x7f6be8db88fa  (/usr/lib/libcurl.so.4+0x708fa) (BuildId: b5fe52836b4db517485d04822e61ce49b2793833)

Indirect leak of 5376 byte(s) in 2 object(s) allocated from:
    #0 0x564b473d8839 in malloc (kodi-test+0xa2a8839) (BuildId: e17174d164cea5687c750d197e31e6bf0beb86ad)
    xbmc#1 0x7f6be8d79a44  (/usr/lib/libcurl.so.4+0x31a44) (BuildId: b5fe52836b4db517485d04822e61ce49b2793833)
[...]
@neo1973 neo1973 added Type: Fix non-breaking change which fixes an issue v21 Omega labels Dec 10, 2023
@neo1973 neo1973 added this to the Omega 21.0 RC1 milestone Dec 10, 2023
@neo1973 neo1973 changed the title [DllLibCurl][TestXBMCTinyXML2] Fix memroy leaks [DllLibCurl][TestXBMCTinyXML2] Fix memory leaks Dec 10, 2023
@fuzzard fuzzard merged commit 56f8d24 into xbmc:master Dec 11, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Fix non-breaking change which fixes an issue v21 Omega
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants