Boost logo

Boost :

Subject: [boost] Fwd: [Boost C++ Libraries] #4922: memory leak in boost::iostreams::detail::chain_impl::~chain_impl()
From: Виктор Шугаев (victor.shugaev_at_[hidden])
Date: 2011-06-10 03:57:26


Hi,

more than a half year ago I found memory leak in boost.iostreams library.
I wrote a patch and created a ticket (#4922).
But it seems that nobody mantains this library.

It is critical for my work.

-- 
Thanks in advance,
Victor
-------- Исходное сообщение --------
Тема: 	[Boost C++ Libraries] #4922: memory leak in 
boost::iostreams::detail::chain_impl::~chain_impl()
Дата: 	Thu, 02 Dec 2010 12:25:38 -0000
От: 	Boost C++ Libraries <noreply_at_[hidden]>
Копия: 	boost-bugs_at_[hidden]
#4922: memory leak in boost::iostreams::detail::chain_impl::~chain_impl()
--------------------------------------+-------------------------------------
  Reporter:  victor.shugaev@…          |       Owner:  turkanis
      Type:  Patches                   |      Status:  new
Milestone:  To Be Determined          |   Component:  iostreams
   Version:  Boost 1.45.0              |    Severity:  Problem
  Keywords:                            |
--------------------------------------+-------------------------------------
  It appears that there are some cases when the ''chain_impl::close()''
  ('''boost/iostreams/chain.hpp''') throws an exception. If it is invoked
  from
  {{{
  ~chain_impl() { try { close(); reset(); } catch (...) { } }
  }}}
  the following ''reset()'' method won't be invoked and it results in memory
  leak because of there is a ''delete buf;'' invokation in the ''reset()''.
  Patch file is attached.
  Also I have managed to produce such a situation (example is attached).
  Below shows that the ''gzip_decompressor'' was constructed 4 times (1 time
  by default constructor and 3 times by copy constructor), but destroyed
  only 3 times. Destructor for object at 0x4e46b98 wasn't invoked.
  ----
  $ valgrind ./leak_example[[BR]]
  ==18153== Memcheck, a memory error detector[[BR]]
  ==18153== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et
  al.[[BR]]
  ==18153== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright
  info[[BR]]
  ==18153== Command: ./leak_example[[BR]]
  ==18153==[[BR]]
  '''gzip_decompressor has been constructed at: 0x7ff0007c0[[BR]]
  gzip_decompressor has been copy constructed from: 0x7ff0007c0 at:
  0x7ff000450[[BR]]
  gzip_decompressor has been copy constructed from: 0x7ff000450 at:
  0x7ff000320[[BR]]
  gzip_decompressor has been copy constructed from: 0x7ff000320 at:
  0x4e46b98[[BR]]
  gzip_decompressor has been destroyed at: 0x7ff000320[[BR]]
  gzip_decompressor has been destroyed at: 0x7ff000450[[BR]]
  gzip_decompressor has been destroyed at: 0x7ff0007c0'''[[BR]]
  ==18153==[[BR]]
  ==18153== HEAP SUMMARY:[[BR]]
  ==18153==     in use at exit: 51,493 bytes in 13 blocks[[BR]]
  ==18153==   total heap usage: 28 allocs, 15 frees, 69,665 bytes
  allocated[[BR]]
  ==18153==[[BR]]
  ==18153== LEAK SUMMARY:[[BR]]
  ==18153==    '''definitely lost: 216 bytes in 1 blocks'''[[BR]]
  ==18153==    indirectly lost: 51,277 bytes in 12 blocks[[BR]]
  ==18153==      possibly lost: 0 bytes in 0 blocks[[BR]]
  ==18153==    still reachable: 0 bytes in 0 blocks[[BR]]
  ==18153==         suppressed: 0 bytes in 0 blocks[[BR]]
  ==18153== Rerun with --leak-check=full to see details of leaked
  memory[[BR]]
  ==18153==[[BR]]
  ==18153== For counts of detected and suppressed errors, rerun with:
  -v[[BR]]
  ==18153== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from
  4)[[BR]]
-- 
Ticket URL:<https://svn.boost.org/trac/boost/ticket/4922>
Boost C++ Libraries<http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk