id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 9185,boost::container::vector leaks memory,TeXitoi,Ion Gaztañaga,"boost::container::vector may leak memory with allocation of size 0. For example, on Debian with libboost1.54-dev 1.54.0-2, with this program: {{{ #include int main() { using namespace boost::container; vector v1; vector v2(v1); return 0; } }}} I have {{{ $ valgrind --leak-check=full ./test ==15591== Memcheck, a memory error detector ==15591== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al. ==15591== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info ==15591== Command: ./test ==15591== ==15591== ==15591== HEAP SUMMARY: ==15591== in use at exit: 0 bytes in 1 blocks ==15591== total heap usage: 1 allocs, 0 frees, 0 bytes allocated ==15591== ==15591== 0 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==15591== at 0x4C298F9: operator new(unsigned long) (vg_replace_malloc.c:298) ==15591== by 0x4017F6: __gnu_cxx::new_allocator::allocate(unsigned long, void const*) (new_allocator.h:104) ==15591== by 0x4015FC: boost::container::container_detail::allocator_version_traits, 1u>::allocation_command(std::allocator&, int, unsigned long, unsigned long, unsigned long&, int* const&) (allocator_version_traits.hpp:144) ==15591== by 0x401542: boost::container::container_detail::vector_alloc_holder, boost::container::container_detail::integral_constant >::allocation_command(int, unsigned long, unsigned long, unsigned long&, int* const&) (vector.hpp:395) ==15591== by 0x401474: boost::container::container_detail::vector_alloc_holder, boost::container::container_detail::integral_constant >::vector_alloc_holder >(std::allocator const&, unsigned long) (vector.hpp:350) ==15591== by 0x401104: boost::container::container_detail::vector_alloc_holder, boost::container::container_detail::integral_constant >::vector_alloc_holder >(std::allocator const&, unsigned long) (vector.hpp:351) ==15591== by 0x401007: boost::container::vector >::vector(boost::container::vector > const&) (vector.hpp:732) ==15591== by 0x400F6C: boost::container::vector >::vector(boost::container::vector > const&) (vector.hpp:737) ==15591== by 0x400EBB: main (test.cpp:10) ==15591== ==15591== LEAK SUMMARY: ==15591== definitely lost: 0 bytes in 1 blocks ==15591== indirectly lost: 0 bytes in 0 blocks ==15591== possibly lost: 0 bytes in 0 blocks ==15591== still reachable: 0 bytes in 0 blocks ==15591== suppressed: 0 bytes in 0 blocks ==15591== ==15591== For counts of detected and suppressed errors, rerun with: -v ==15591== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 2 from 2) }}} I suspect that {{{ ~vector_alloc_holder() BOOST_CONTAINER_NOEXCEPT { if(this->m_capacity){ this->alloc().deallocate(this->m_start, this->m_capacity); } } }}} should be {{{ ~vector_alloc_holder() BOOST_CONTAINER_NOEXCEPT { if(this->m_start){ this->alloc().deallocate(this->m_start, this->m_capacity); } } }}} (not tested).",Bugs,closed,To Be Determined,container,Boost 1.54.0,Problem,duplicate,,