id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 12296,"boost::container::{deque,string} combine for a memory leak",Tavian Barnes ,Ion Gaztañaga,"The following program leaks memory, according to valgrind. Switching either deque or string (or both) to the std:: implementation does not show the leak, so I'm not sure which container has the bug (though I suspect it's deque). {{{ $ cat foo.cpp #include #include #include #include using boost::container::deque; using boost::container::string; // using std::deque; // using std::string; int main() { deque foo; foo.push_back(""------------------------""); foo.push_back(""------------------------""); foo.erase(foo.begin(), foo.begin() + 1); return 0; } $ g++ -std=c++11 -g -Wall foo.cpp && valgrind --leak-check=full ./a.out ==29864== Memcheck, a memory error detector ==29864== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==29864== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==29864== Command: ./a.out ==29864== ==29864== ==29864== HEAP SUMMARY: ==29864== in use at exit: 72,752 bytes in 2 blocks ==29864== total heap usage: 5 allocs, 3 frees, 73,368 bytes allocated ==29864== ==29864== 48 bytes in 1 blocks are definitely lost in loss record 1 of 2 ==29864== at 0x4C2B0D8: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==29864== by 0x405A12: boost::container::new_allocator::allocate(unsigned long) (new_allocator.hpp:145) ==29864== by 0x405047: boost::container::container_detail::allocator_version_traits, 1u>::allocation_command(boost::container::new_allocator&, unsigned int, unsigned long, unsigned long&, char*&) (allocator_version_traits.hpp:142) ==29864== by 0x404647: boost::container::container_detail::basic_string_base >::allocation_command(unsigned int, unsigned long, unsigned long&, char*&) (string.hpp:276) ==29864== by 0x403823: boost::container::basic_string, boost::container::new_allocator >::priv_reserve(unsigned long, bool) (string.hpp:2494) ==29864== by 0x40250B: boost::container::basic_string, boost::container::new_allocator >::reserve(unsigned long) (string.hpp:1088) ==29864== by 0x401922: boost::container::basic_string, boost::container::new_allocator >::assign(char const*, char const*) (string.hpp:1401) ==29864== by 0x4011C9: boost::container::basic_string, boost::container::new_allocator >::basic_string(char const*) (string.hpp:707) ==29864== by 0x400D84: main (foo.cpp:13) ==29864== ==29864== LEAK SUMMARY: ==29864== definitely lost: 48 bytes in 1 blocks ==29864== indirectly lost: 0 bytes in 0 blocks ==29864== possibly lost: 0 bytes in 0 blocks ==29864== still reachable: 72,704 bytes in 1 blocks ==29864== suppressed: 0 bytes in 0 blocks ==29864== Reachable blocks (those to which a pointer was found) are not shown. ==29864== To see them, rerun with: --leak-check=full --show-leak-kinds=all ==29864== ==29864== For counts of detected and suppressed errors, rerun with: -v ==29864== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) }}} (Ignore the ""still reachable"" blocks; those are from libstdc++ itself.)",Bugs,closed,To Be Determined,container,Boost 1.61.0,Problem,fixed,,