Bug #3673
closedValidatorConfig: memory leak in HyperKeyLocatorNameChecker
Added by Junxiao Shi over 8 years ago. Updated almost 8 years ago.
100%
Description
Snippet to reproduce:
// g++ -o x -std=c++0x x.cpp $(pkg-config --cflags --libs libndn-cxx)
#include <ndn-cxx/security/validator-config.hpp>
int main() {
ndn::ValidatorConfig validator;
validator.load(
R"CONFIG(
rule
{
id "rule"
for data
checker
{
type hierarchical
sig-type rsa-sha256
}
}
)CONFIG", "filename"
);
return 0;
}
Valgrind reports RegexBackrefManager
allocated by RegexTopMatcher
allocated by HyperKeyLocatorNameChecker
is definitely lost.
Updated by Junxiao Shi over 8 years ago
Ubuntu 14.04 64-bit
vagrant@m0212:~$ valgrind --leak-check=full ./x
==7210== Memcheck, a memory error detector
==7210== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==7210== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==7210== Command: ./x
==7210==
==7210==
==7210== HEAP SUMMARY:
==7210== in use at exit: 8,407 bytes in 73 blocks
==7210== total heap usage: 455 allocs, 382 frees, 47,686 bytes allocated
==7210==
==7210== 3,113 (56 direct, 3,057 indirect) bytes in 1 blocks are definitely lost in loss record 53 of 54
==7210== at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7210== by 0x50C1810: allocate (new_allocator.h:104)
==7210== by 0x50C1810: allocate (alloc_traits.h:351)
==7210== by 0x50C1810: __shared_count<ndn::RegexBackrefManager, std::allocator<ndn::RegexBackrefManager> > (shared_ptr_base.h:499)
==7210== by 0x50C1810: __shared_ptr<std::allocator<ndn::RegexBackrefManager> > (shared_ptr_base.h:957)
==7210== by 0x50C1810: shared_ptr<std::allocator<ndn::RegexBackrefManager> > (shared_ptr.h:316)
==7210== by 0x50C1810: allocate_shared<ndn::RegexBackrefManager, std::allocator<ndn::RegexBackrefManager> > (shared_ptr.h:598)
==7210== by 0x50C1810: make_shared<ndn::RegexBackrefManager> (shared_ptr.h:614)
==7210== by 0x50C1810: ndn::RegexTopMatcher::RegexTopMatcher(std::string const&, std::string const&) (regex-top-matcher.cpp:38)
==7210== by 0x506A5BA: ndn::security::conf::HyperKeyLocatorNameChecker::HyperKeyLocatorNameChecker(std::string const&, std::string, std::string const&, std::string, ndn::security::conf::KeyLocatorChecker::Relation const&) (key-locator-checker.hpp:188)
==7210== by 0x5072201: construct<ndn::security::conf::HyperKeyLocatorNameChecker, char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (new_allocator.h:120)
==7210== by 0x5072201: _S_construct<ndn::security::conf::HyperKeyLocatorNameChecker, char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (alloc_traits.h:254)
==7210== by 0x5072201: construct<ndn::security::conf::HyperKeyLocatorNameChecker, char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (alloc_traits.h:393)
==7210== by 0x5072201: _Sp_counted_ptr_inplace<char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (shared_ptr_base.h:399)
==7210== by 0x5072201: construct<std::_Sp_counted_ptr_inplace<ndn::security::conf::HyperKeyLocatorNameChecker, std::allocator<ndn::security::conf::HyperKeyLocatorNameChecker>, (__gnu_cxx::_Lock_policy)2u>, const std::allocator<ndn::security::conf::HyperKeyLocatorNameChecker>, char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (new_allocator.h:120)
==7210== by 0x5072201: _S_construct<std::_Sp_counted_ptr_inplace<ndn::security::conf::HyperKeyLocatorNameChecker, std::allocator<ndn::security::conf::HyperKeyLocatorNameChecker>, (__gnu_cxx::_Lock_policy)2u>, const std::allocator<ndn::security::conf::HyperKeyLocatorNameChecker>, char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (alloc_traits.h:254)
==7210== by 0x5072201: construct<std::_Sp_counted_ptr_inplace<ndn::security::conf::HyperKeyLocatorNameChecker, std::allocator<ndn::security::conf::HyperKeyLocatorNameChecker>, (__gnu_cxx::_Lock_policy)2u>, const std::allocator<ndn::security::conf::HyperKeyLocatorNameChecker>, char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (alloc_traits.h:393)
==7210== by 0x5072201: __shared_count<ndn::security::conf::HyperKeyLocatorNameChecker, std::allocator<ndn::security::conf::HyperKeyLocatorNameChecker>, char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (shared_ptr_base.h:502)
==7210== by 0x5072201: __shared_ptr<std::allocator<ndn::security::conf::HyperKeyLocatorNameChecker>, char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (shared_ptr_base.h:957)
==7210== by 0x5072201: shared_ptr<std::allocator<ndn::security::conf::HyperKeyLocatorNameChecker>, char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (shared_ptr.h:316)
==7210== by 0x5072201: allocate_shared<ndn::security::conf::HyperKeyLocatorNameChecker, std::allocator<ndn::security::conf::HyperKeyLocatorNameChecker>, char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (shared_ptr.h:598)
==7210== by 0x5072201: make_shared<ndn::security::conf::HyperKeyLocatorNameChecker, char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (shared_ptr.h:614)
==7210== by 0x5072201: HierarchicalChecker (checker.hpp:229)
==7210== by 0x5072201: construct<ndn::security::conf::HierarchicalChecker, unsigned int> (new_allocator.h:120)
==7210== by 0x5072201: _S_construct<ndn::security::conf::HierarchicalChecker, unsigned int> (alloc_traits.h:254)
==7210== by 0x5072201: construct<ndn::security::conf::HierarchicalChecker, unsigned int> (alloc_traits.h:393)
==7210== by 0x5072201: _Sp_counted_ptr_inplace<unsigned int> (shared_ptr_base.h:399)
==7210== by 0x5072201: construct<std::_Sp_counted_ptr_inplace<ndn::security::conf::HierarchicalChecker, std::allocator<ndn::security::conf::HierarchicalChecker>, (__gnu_cxx::_Lock_policy)2u>, const std::allocator<ndn::security::conf::HierarchicalChecker>, unsigned int> (new_allocator.h:120)
==7210== by 0x5072201: _S_construct<std::_Sp_counted_ptr_inplace<ndn::security::conf::HierarchicalChecker, std::allocator<ndn::security::conf::HierarchicalChecker>, (__gnu_cxx::_Lock_policy)2u>, const std::allocator<ndn::security::conf::HierarchicalChecker>, unsigned int> (alloc_traits.h:254)
==7210== by 0x5072201: construct<std::_Sp_counted_ptr_inplace<ndn::security::conf::HierarchicalChecker, std::allocator<ndn::security::conf::HierarchicalChecker>, (__gnu_cxx::_Lock_policy)2u>, const std::allocator<ndn::security::conf::HierarchicalChecker>, unsigned int> (alloc_traits.h:393)
==7210== by 0x5072201: __shared_count<ndn::security::conf::HierarchicalChecker, std::allocator<ndn::security::conf::HierarchicalChecker>, unsigned int> (shared_ptr_base.h:502)
==7210== by 0x5072201: __shared_ptr<std::allocator<ndn::security::conf::HierarchicalChecker>, unsigned int> (shared_ptr_base.h:957)
==7210== by 0x5072201: shared_ptr<std::allocator<ndn::security::conf::HierarchicalChecker>, unsigned int> (shared_ptr.h:316)
==7210== by 0x5072201: allocate_shared<ndn::security::conf::HierarchicalChecker, std::allocator<ndn::security::conf::HierarchicalChecker>, unsigned int> (shared_ptr.h:598)
==7210== by 0x5072201: make_shared<ndn::security::conf::HierarchicalChecker, unsigned int> (shared_ptr.h:614)
==7210== by 0x5072201: ndn::security::conf::CheckerFactory::createHierarchicalChecker(boost::property_tree::basic_ptree<std::string, std::string, std::less<std::string> > const&, std::string const&) (checker.hpp:452)
==7210== by 0x507D03E: ndn::security::conf::CheckerFactory::create(boost::property_tree::basic_ptree<std::string, std::string, std::less<std::string> > const&, std::string const&) (checker.hpp:399)
==7210== by 0x5063D21: ndn::ValidatorConfig::onConfigRule(boost::property_tree::basic_ptree<std::string, std::string, std::less<std::string> > const&, std::string const&) (validator-config.cpp:214)
==7210== by 0x50662FB: ndn::ValidatorConfig::load(boost::property_tree::basic_ptree<std::string, std::string, std::less<std::string> > const&, std::string const&) (validator-config.cpp:144)
==7210== by 0x5066606: ndn::ValidatorConfig::load(std::istream&, std::string const&) (validator-config.cpp:116)
==7210== by 0x5066D6E: ndn::ValidatorConfig::load(std::string const&, std::string const&) (validator-config.cpp:95)
==7210== by 0x403C55: main (in /home/vagrant/x)
==7210==
==7210== 5,294 (56 direct, 5,238 indirect) bytes in 1 blocks are definitely lost in loss record 54 of 54
==7210== at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7210== by 0x50C1810: allocate (new_allocator.h:104)
==7210== by 0x50C1810: allocate (alloc_traits.h:351)
==7210== by 0x50C1810: __shared_count<ndn::RegexBackrefManager, std::allocator<ndn::RegexBackrefManager> > (shared_ptr_base.h:499)
==7210== by 0x50C1810: __shared_ptr<std::allocator<ndn::RegexBackrefManager> > (shared_ptr_base.h:957)
==7210== by 0x50C1810: shared_ptr<std::allocator<ndn::RegexBackrefManager> > (shared_ptr.h:316)
==7210== by 0x50C1810: allocate_shared<ndn::RegexBackrefManager, std::allocator<ndn::RegexBackrefManager> > (shared_ptr.h:598)
==7210== by 0x50C1810: make_shared<ndn::RegexBackrefManager> (shared_ptr.h:614)
==7210== by 0x50C1810: ndn::RegexTopMatcher::RegexTopMatcher(std::string const&, std::string const&) (regex-top-matcher.cpp:38)
==7210== by 0x506A611: ndn::security::conf::HyperKeyLocatorNameChecker::HyperKeyLocatorNameChecker(std::string const&, std::string, std::string const&, std::string, ndn::security::conf::KeyLocatorChecker::Relation const&) (key-locator-checker.hpp:189)
==7210== by 0x5072201: construct<ndn::security::conf::HyperKeyLocatorNameChecker, char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (new_allocator.h:120)
==7210== by 0x5072201: _S_construct<ndn::security::conf::HyperKeyLocatorNameChecker, char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (alloc_traits.h:254)
==7210== by 0x5072201: construct<ndn::security::conf::HyperKeyLocatorNameChecker, char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (alloc_traits.h:393)
==7210== by 0x5072201: _Sp_counted_ptr_inplace<char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (shared_ptr_base.h:399)
==7210== by 0x5072201: construct<std::_Sp_counted_ptr_inplace<ndn::security::conf::HyperKeyLocatorNameChecker, std::allocator<ndn::security::conf::HyperKeyLocatorNameChecker>, (__gnu_cxx::_Lock_policy)2u>, const std::allocator<ndn::security::conf::HyperKeyLocatorNameChecker>, char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (new_allocator.h:120)
==7210== by 0x5072201: _S_construct<std::_Sp_counted_ptr_inplace<ndn::security::conf::HyperKeyLocatorNameChecker, std::allocator<ndn::security::conf::HyperKeyLocatorNameChecker>, (__gnu_cxx::_Lock_policy)2u>, const std::allocator<ndn::security::conf::HyperKeyLocatorNameChecker>, char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (alloc_traits.h:254)
==7210== by 0x5072201: construct<std::_Sp_counted_ptr_inplace<ndn::security::conf::HyperKeyLocatorNameChecker, std::allocator<ndn::security::conf::HyperKeyLocatorNameChecker>, (__gnu_cxx::_Lock_policy)2u>, const std::allocator<ndn::security::conf::HyperKeyLocatorNameChecker>, char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (alloc_traits.h:393)
==7210== by 0x5072201: __shared_count<ndn::security::conf::HyperKeyLocatorNameChecker, std::allocator<ndn::security::conf::HyperKeyLocatorNameChecker>, char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (shared_ptr_base.h:502)
==7210== by 0x5072201: __shared_ptr<std::allocator<ndn::security::conf::HyperKeyLocatorNameChecker>, char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (shared_ptr_base.h:957)
==7210== by 0x5072201: shared_ptr<std::allocator<ndn::security::conf::HyperKeyLocatorNameChecker>, char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (shared_ptr.h:316)
==7210== by 0x5072201: allocate_shared<ndn::security::conf::HyperKeyLocatorNameChecker, std::allocator<ndn::security::conf::HyperKeyLocatorNameChecker>, char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (shared_ptr.h:598)
==7210== by 0x5072201: make_shared<ndn::security::conf::HyperKeyLocatorNameChecker, char const (&)[8], char const (&)[3], char const (&)[41], char const (&)[5], ndn::security::conf::KeyLocatorChecker::Relation> (shared_ptr.h:614)
==7210== by 0x5072201: HierarchicalChecker (checker.hpp:229)
==7210== by 0x5072201: construct<ndn::security::conf::HierarchicalChecker, unsigned int> (new_allocator.h:120)
==7210== by 0x5072201: _S_construct<ndn::security::conf::HierarchicalChecker, unsigned int> (alloc_traits.h:254)
==7210== by 0x5072201: construct<ndn::security::conf::HierarchicalChecker, unsigned int> (alloc_traits.h:393)
==7210== by 0x5072201: _Sp_counted_ptr_inplace<unsigned int> (shared_ptr_base.h:399)
==7210== by 0x5072201: construct<std::_Sp_counted_ptr_inplace<ndn::security::conf::HierarchicalChecker, std::allocator<ndn::security::conf::HierarchicalChecker>, (__gnu_cxx::_Lock_policy)2u>, const std::allocator<ndn::security::conf::HierarchicalChecker>, unsigned int> (new_allocator.h:120)
==7210== by 0x5072201: _S_construct<std::_Sp_counted_ptr_inplace<ndn::security::conf::HierarchicalChecker, std::allocator<ndn::security::conf::HierarchicalChecker>, (__gnu_cxx::_Lock_policy)2u>, const std::allocator<ndn::security::conf::HierarchicalChecker>, unsigned int> (alloc_traits.h:254)
==7210== by 0x5072201: construct<std::_Sp_counted_ptr_inplace<ndn::security::conf::HierarchicalChecker, std::allocator<ndn::security::conf::HierarchicalChecker>, (__gnu_cxx::_Lock_policy)2u>, const std::allocator<ndn::security::conf::HierarchicalChecker>, unsigned int> (alloc_traits.h:393)
==7210== by 0x5072201: __shared_count<ndn::security::conf::HierarchicalChecker, std::allocator<ndn::security::conf::HierarchicalChecker>, unsigned int> (shared_ptr_base.h:502)
==7210== by 0x5072201: __shared_ptr<std::allocator<ndn::security::conf::HierarchicalChecker>, unsigned int> (shared_ptr_base.h:957)
==7210== by 0x5072201: shared_ptr<std::allocator<ndn::security::conf::HierarchicalChecker>, unsigned int> (shared_ptr.h:316)
==7210== by 0x5072201: allocate_shared<ndn::security::conf::HierarchicalChecker, std::allocator<ndn::security::conf::HierarchicalChecker>, unsigned int> (shared_ptr.h:598)
==7210== by 0x5072201: make_shared<ndn::security::conf::HierarchicalChecker, unsigned int> (shared_ptr.h:614)
==7210== by 0x5072201: ndn::security::conf::CheckerFactory::createHierarchicalChecker(boost::property_tree::basic_ptree<std::string, std::string, std::less<std::string> > const&, std::string const&) (checker.hpp:452)
==7210== by 0x507D03E: ndn::security::conf::CheckerFactory::create(boost::property_tree::basic_ptree<std::string, std::string, std::less<std::string> > const&, std::string const&) (checker.hpp:399)
==7210== by 0x5063D21: ndn::ValidatorConfig::onConfigRule(boost::property_tree::basic_ptree<std::string, std::string, std::less<std::string> > const&, std::string const&) (validator-config.cpp:214)
==7210== by 0x50662FB: ndn::ValidatorConfig::load(boost::property_tree::basic_ptree<std::string, std::string, std::less<std::string> > const&, std::string const&) (validator-config.cpp:144)
==7210== by 0x5066606: ndn::ValidatorConfig::load(std::istream&, std::string const&) (validator-config.cpp:116)
==7210== by 0x5066D6E: ndn::ValidatorConfig::load(std::string const&, std::string const&) (validator-config.cpp:95)
==7210== by 0x403C55: main (in /home/vagrant/x)
==7210==
==7210== LEAK SUMMARY:
==7210== definitely lost: 112 bytes in 2 blocks
==7210== indirectly lost: 8,295 bytes in 71 blocks
==7210== possibly lost: 0 bytes in 0 blocks
==7210== still reachable: 0 bytes in 0 blocks
==7210== suppressed: 0 bytes in 0 blocks
==7210==
==7210== For counts of detected and suppressed errors, rerun with: -v
==7210== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
OSX 10.11 (partial)
==22937== 3,000 (56 direct, 2,944 indirect) bytes in 1 blocks are definitely lost in loss record 335 of 342
==22937== at 0x10001145B: malloc (in /usr/local/Cellar/valgrind/HEAD/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==22937== by 0x101A857DD: operator new(unsigned long) (in /usr/lib/libc++.1.dylib)
==22937== by 0x1000AEB6E: std::__1::shared_ptr<ndn::RegexBackrefManager> std::__1::shared_ptr<ndn::RegexBackrefManager>::make_shared<>() (in /usr/local/lib/libndn-cxx.0.4.1.dylib)
==22937== by 0x1003003B3: ndn::RegexTopMatcher::RegexTopMatcher(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in /usr/local/lib/libndn-cxx.0.4.1.dylib)
==22937== by 0x100300784: ndn::RegexTopMatcher::RegexTopMatcher(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in /usr/local/lib/libndn-cxx.0.4.1.dylib)
==22937== by 0x1002015AA: ndn::security::conf::HyperKeyLocatorNameChecker::HyperKeyLocatorNameChecker(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, ndn::security::conf::KeyLocatorChecker::Relation const&) (in /usr/local/lib/libndn-cxx.0.4.1.dylib)
==22937== by 0x10020011C: ndn::security::conf::HyperKeyLocatorNameChecker::HyperKeyLocatorNameChecker(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, ndn::security::conf::KeyLocatorChecker::Relation const&) (in /usr/local/lib/libndn-cxx.0.4.1.dylib)
==22937== by 0x1002081D8: std::__1::shared_ptr<ndn::security::conf::HyperKeyLocatorNameChecker> std::__1::shared_ptr<ndn::security::conf::HyperKeyLocatorNameChecker>::make_shared<char const (&) [8], char const (&) [3], char const (&) [41], char const (&) [5], ndn::security::conf::KeyLocatorChecker::Relation>(char const (&) [8], char const (&) [3], char const (&) [41], char const (&) [5], ndn::security::conf::KeyLocatorChecker::Relation&&) (in /usr/local/lib/libndn-cxx.0.4.1.dylib)
==22937== by 0x1002073FE: ndn::security::conf::HierarchicalChecker::HierarchicalChecker(unsigned int) (in /usr/local/lib/libndn-cxx.0.4.1.dylib)
==22937== by 0x10020732A: ndn::security::conf::HierarchicalChecker::HierarchicalChecker(unsigned int) (in /usr/local/lib/libndn-cxx.0.4.1.dylib)
==22937== by 0x100206E75: std::__1::shared_ptr<ndn::security::conf::HierarchicalChecker> std::__1::shared_ptr<ndn::security::conf::HierarchicalChecker>::make_shared<unsigned int>(unsigned int&&) (in /usr/local/lib/libndn-cxx.0.4.1.dylib)
==22937== by 0x1001FBF3E: ndn::security::conf::CheckerFactory::createHierarchicalChecker(boost::property_tree::basic_ptree<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in /usr/local/lib/libndn-cxx.0.4.1.dylib)
==22937==
Updated by Junxiao Shi about 8 years ago
- Category changed from Security to Utils
This leak is coming from regex, and it's caused by circular shared_ptrs.
// g++ -o x -std=c++0x x.cpp $(pkg-config --cflags --libs libndn-cxx)
#include <ndn-cxx/util/regex.hpp>
#include <iostream>
using namespace ndn;
int main()
{
auto re = make_unique<Regex>("^(<>)$");
weak_ptr<RegexPatternListMatcher> m1(re->m_primaryMatcher);
weak_ptr<RegexPatternListMatcher> m2(re->m_secondaryMatcher);
weak_ptr<RegexBackrefManager> b1(re->m_primaryBackrefManager);
weak_ptr<RegexBackrefManager> b2(re->m_secondaryBackrefManager);
re.reset();
std::cout << m1.use_count() << ' ' << m2.use_count() << ' ' << b1.use_count() << ' ' << b2.use_count() << '\n';
return 0;
}
This prints "0 0 5 0", which means shared_ptr to m_primaryBackrefManager
is held by some objects.
Updated by Junxiao Shi almost 8 years ago
- Status changed from New to In Progress
- Assignee changed from Zhiyi Zhang to Junxiao Shi
- Target version changed from v0.5 to v0.6
Updated by Junxiao Shi almost 8 years ago
- Status changed from In Progress to Code review
- % Done changed from 0 to 100
I've identified the memory leak to be caused by RegexMatcher::m_backrefManager
and RegexBackrefManager::m_backrefs
owning each other.
https://gerrit.named-data.net/3351 corrects code style in src/util/regex/*
.
https://gerrit.named-data.net/3352 plugs the memory leak.
Updated by Junxiao Shi almost 8 years ago
- Status changed from Code review to New
- Assignee deleted (
Junxiao Shi) - % Done changed from 100 to 0
Since reviewer/dictator is unwilling to approve my changes, I'm withdrawing my contributions.
Updated by Alex Afanasyev almost 8 years ago
- Status changed from New to Closed
- Assignee set to Junxiao Shi
- % Done changed from 0 to 100